- Home /
My moving object decelerates when almost reaching a next point in the bezier curve,My gameobject decelerates when reaching a next point
I have an object which is supposed to follow a curve, but it keeps decelerating when it almost reaches a next point within the curve. Then it accelerates into its normal speed again after having passed that point, then it decelerates again at the next point and the cycle continues. I think this might be because each next segment of the curve is unknown to the object, but I might be wrong.
Do you guys know how to keep the velocity of the object in a constant manner without having it decelerating or accelerating...?
Comment
$$anonymous$$aybe give us a piece of the code. Easier to identify the problem.
protected override void OnUpdate() { base.OnUpdate();
// Calculate progress in float.
progress += Time.deltaTime / duration;
// Deter$$anonymous$$e next point at progress
// $$anonymous$$ethod: Get_Pt_At must calculate that particular cubic segment first
// based on the current time ( i.e. progress ).
// Then it retrieves the point
// using the first and end pts of that specific segment.
next_pt = the_curve. Get_Pt_At ( progress );
// Ter$$anonymous$$ate or move to next point
if ( progress >= endPointProgress)
{
index = 0; // Reset the index for the next loop
EndAction();
return;
}
else
{
// $$anonymous$$ethod: Go_To deter$$anonymous$$es the lookat and of course its next position.
Go_To(next_pt);
}
}