- Home /
Move RigidBody along curve
I have parametric Bezier curve. Given position on the curve by parametr "t", I can calculate position and rotation. I can set this directly to transform component.
But this is not using RigidBody collisions. How can I control movement along curve with AddForce ?
Answer by OncaLupe · Nov 22, 2015 at 03:45 PM
I'd suggest looking at the functions available to Rigidbodies.
http://docs.unity3d.com/ScriptReference/Rigidbody.html
Specifically these:
http://docs.unity3d.com/ScriptReference/Rigidbody.MovePosition.html http://docs.unity3d.com/ScriptReference/Rigidbody.MoveRotation.html
Answer by appicarts · Nov 22, 2015 at 05:56 PM
you have to find destination position every frame and apply force accordingly.
AFAIK The problem with bezier curve is that it's rate of change of distance is not proportional to t(parameter). So even if you are increasing t with constant speed the object will not move with constant speed. (Generally it slows down or accelerates in the middle of the curve, based on the control points position).
you can flatten the curve(convert it into a serial of small line) or Google "bezier arc-length parameterization".
After you have parameterized the curve(series of t values for which distance between consecutive t is same), you can take the same approach that you would take if you have to move the object in a straight line.
Your answer

Follow this Question
Related Questions
Rigidbody Weird... Physics... or not physics... ???? 0 Answers
Is it okay to use ForceMode.VelocityChange in Update()? 1 Answer
How to change CC script to Rigidbody script 1 Answer
How to affect opponent's rigidbody properties using photon networking ? 0 Answers
Velocity Movement & Physics Interactions by Rigidbody2D 0 Answers