Hi, I am trying to get my player to move with a moving platform when on the platform, and I don’t know why this code is not working.
void OnCollisionEnter2D(Collision2D other) {
if(other.transform.tag == "MovingPlatform")
{
transform.parent = other.transform;
}
}
Yes, I do know that the player will continue to move with the platform after exiting collision. Currently, when the player is on the platform, it does not change or do anything. Player is a sprite with Transform, Sprite Renderer, Box Collider 2D, Ridgidbody 2D, and a character movement script. It is also the parent of a main camera and an empty object to detect the ground. Platform is a sprite with Transform, Sprite Renderer, Box Collider 2D, Platform Effector 2D, Ridgidbody 2D (is kinematic), and a movement script. Any information would help.