- Home /
Switching from kinematic to dynamic without stutter
Hello! I am working on a little skate game where the player can grind. The skater is a dynamic rigidbody that I move by applying force. When the player grind on a rail, I switch the player's rigidbody from dynamic to kinematic and use LeanTween's moveSpline function to move the player along the path of the rail. This all works fine, however, when the player reaches the END of the rail and I switch from kinematic to dynamic, it seems like there is a single frame where the player stops moving and it's extremely noticable. I can't seem to figure out why and was looking for some help.
LTDescr tween = LeanTween.moveSpline(rb.gameObject, paths, grindSpeed)
.setOrientToPath2d(false)
.setSpeed(grindSpeed)
.setOnComplete(() =>
{
rb.isKinematic = false;
var afterRailForce = new Vector3(velocityPriorToGrind.x, endRailPop.y, 0);
rb.AddForce(afterRailForce, ForceMode.Impulse);
});
}
After the rail is complete, I take the x velocity prior to the grind starting and add a force to the player's rigidbody AFTER setting isKinematic to false (back to dynamic). Here is what it looks like.
Thanks for the help!
Your answer
Follow this Question
Related Questions
2d kinematic projectile velocity problem 0 Answers
rotate 2d object without affecting the rigidbody ? 1 Answer
How do I prevent a Kinematic Rigidbody2D from moving a Dynamic Rigidbody2D on Collision? 1 Answer
How to not get velocity by the other objects?,How to not get force by other gameobjects? 0 Answers
Why my rigidbody2D not working when I switch it to dynamic? 0 Answers