- Home /
Question by
JakeBryn · Nov 11, 2010 at 03:10 AM ·
raycastingforcerigidbodies
Raycast push? How?
Hey guys I'm trying to make a script that when both the fire1 input is down and a raycast is hitting an object, it pushes it away from the player, like as if it got hit by a bullet. Obviously the best way to do this would be to assign the object a rigidbody and have it so that it applies a force, but how do i make the direction of applied force be AWAY from the player?
Comment
Best Answer
Answer by Loius · Nov 11, 2010 at 03:14 AM
direction = endpoint - startpoint
So,
force = (pushedObject.position - player.position) * scalarMultiplier
Your answer
Follow this Question
Related Questions
Getting Force to work properly 1 Answer
I want to punch a block along a path / rail 1 Answer
Stopping Rigidbodies with Opposing Forces 4 Answers
Add Force without Rotation 2 Answers
Rigidbody rotate around 2 Answers