Zecrit
|
  |
| Joined: 24 Jan 2013 |
| Total Posts: 2618 |
|
|
| 09 Sep 2014 12:17 PM |
I've got the "from a part" bit down, but how do I make the ray point at a bit of an angle to that? I saw it in a script once. |
|
|
| Report Abuse |
|
| |
Zecrit
|
  |
| Joined: 24 Jan 2013 |
| Total Posts: 2618 |
|
| |
|
| 09 Sep 2014 12:42 PM |
Zecrit,
You can do this one of two ways. One way is to use a bit of math and angle the rotation matrix. That sounds like fun, but there is an easier way.
Your ray has a direction, and the solution should have come to people very simple. All that needs to be done is shift the direction slightly. Imagine it. Ray coming from a pay at the intended direction, but not imagine one of the axes shifted slightly.
Rotate the vector. You can get the angle of the vector using the arc cosine of the dot product between them and a normal, but we'll skip that and attempt something similar.
function RandomFixedFloat() local SetVals = math.random(-1,1); local Return; if (SetVals >= 0) Return = SetVals - math.random(); else Return = SetVals + math.random(); end return Return; end
local RandomizeAngle = Vector3.new(RandomFixedFloat(),RandomFixedFloat(),RandomFixedFloat()); Ray.new(PositionToStartRay, Direction * RandomizeAngle ); |
|
|
| Report Abuse |
|