You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When we disable the PlatformerMotor2D to handle the physics by the Rigidbody2D and then again enable the PlatformerMotor2D to gain the control of the character, the rigidbody velocity should be zeroed otherwise the character will tend to move around using the previous velocity.
I have inserted a line of code in PlatformerMotor2D.OnEnable() and that solves my problem:
private void OnEnable()
{
if (_rigidbody2D != null)
{
_velocity = _rigidbody2D.velocity;
_rigidbody2D.velocity = Vector2.zero; //I have added this to solve the problem.
_originalKinematic = _rigidbody2D.isKinematic;
_rigidbody2D.isKinematic = true;
}
}
The text was updated successfully, but these errors were encountered:
When we disable the PlatformerMotor2D to handle the physics by the Rigidbody2D and then again enable the PlatformerMotor2D to gain the control of the character, the rigidbody velocity should be zeroed otherwise the character will tend to move around using the previous velocity.
I have inserted a line of code in PlatformerMotor2D.OnEnable() and that solves my problem:
The text was updated successfully, but these errors were encountered: