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 make a projectile travel along a raycast

Previous Thread :: Next Thread 
doneyes is not online. doneyes
Joined: 21 Mar 2008
Total Posts: 3466
04 May 2013 09:28 PM
How can I use this line:

ray = Ray.new(torso.CFrame.p+Vector3.new(x,y,z),(target.CFrame.p - torso.CFrame.p).unit * 500)

to shoot a projectile along it?
Report Abuse
1Topcop is not online. 1Topcop
Joined: 09 Jun 2009
Total Posts: 6635
04 May 2013 09:33 PM
If the bullet is anchored, use CFrame, if it's not you can use BodyPosition.

Example with BodyPosition,

ray,endPos = -- Workspace:FindPartOnRay(--[[ stuff ]])
bullet.BodyPosition.position = endPos

Example with CFrame,
startPos = bullet.Position
distance = (endPos-startPos).magnitude
for n=0,loop,.1 do
bullet.CFrame = CFrame.new(startPos,endPos)*CFrame.new(0,0,n)
wait()end
-- At least, I think this is how I did it with CFrame. :P


This what you meant?
Report Abuse
pwnedu46 is not online. pwnedu46
Joined: 23 May 2009
Total Posts: 7534
04 May 2013 09:37 PM
If it's just a projectile, you don't need a ray. Just make a part, apply a BodyVelocity in the direction that the gun is pointing, and add a BodyForce of

Vector3.new(0, bullet:GetMass()*195.5, 0) to offset gravity.
Report Abuse
doneyes is not online. doneyes
Joined: 21 Mar 2008
Total Posts: 3466
04 May 2013 10:00 PM
thanks, I got it working.
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
04 May 2013 10:15 PM
196.2 actually :P
It's 20x earth's gravity; 9.81.
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