generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: How to raycast from a part at an angle?

Previous Thread :: Next Thread 
Zecrit is not online. 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
VoidHackII is not online. VoidHackII
Joined: 02 Oct 2012
Total Posts: 2275
09 Sep 2014 12:18 PM
Use a flashlight.
Report Abuse
Zecrit is not online. Zecrit
Joined: 24 Jan 2013
Total Posts: 2618
09 Sep 2014 12:27 PM
You silly child.
Gragh
Report Abuse
DrMathematica is not online. DrMathematica
Joined: 29 Aug 2008
Total Posts: 27268
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image