Player not sticking to moving platform

Hello!

I have an issue with my moving platforms.
I’m trying to get the player to follow the platform and not slide around.

So I’ve tried this bit of code:

void OnCollisionEnter2D(Collision2D other)
{
    if (other.transform.tag == "movingPlatform")
    {
        player.isKinematic = true;
        transform.parent = other.transform;
    }
}

But as you can see in the below images, the parenting process mucks up the size of the player.
I’m not sure why because if I manually parent the player it works fine.

Any ideas as to how to fix this?

Hello @Sabrekitty

This happens because the first parent and the new parent (platform) does not have the same
Transform.localScale .

Transform

You have then 2 options:

1- Run the game in the editor, and once the character changes size, resize it manually, and copy the new transform values. Then at the script, after changing the parent, change it transforms with the saved values

2- Make all scales of all platforms (1, 1, 1) to prevent deforming when changing parents.