Question by
Cyntrac · Mar 26, 2020 at 04:09 PM ·
2d game2d-platformerplatformerplatformmoving platform
Player gets stuck on moving platform
I have this simple moving platform code but the player gets stuck on the platform only some of the time... Sometimes it works perfectly. Can anyone help? :(
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.CompareTag("Moving"))
{
this.transform.parent = collision.transform;
}
if (Input.GetButtonDown("Jump"))
{
this.transform.parent = null;
}
}
private void OnCollisionExit2D(Collision2D collision)
{
if (collision.gameObject.CompareTag("Moving"))
this.transform.parent = null;
}
Comment