Unity rb Player not sticking to a moving platform

I’m working on 2D Unity game. I want to make a moving platform on which player can stand, move, jump.

Player is dynamic Rigidbody2D with this settings

175412-1.png

Platform is kinematic Rigidbody2D with this settings

175413-2.png

For moving player I’m using velocity

private void FixedUpdate()
{
    rb.velocity = new Vector2(moveInput * speed, rb.velocity.y);
}

For moving platform I’m using MovePosition

private void FixedUpdate()
{
rb.MovePosition(transform.position + transform.right * Time.deltaTime);
}

Player doesn’t stick on platform, when platform gone player will fail down (because of gravity)

The Player must be dynamic Rigidbody2D, the platform does not have to be kinematic Rigidbody2D.

But when I remove physics from platform (also set player to be child of platform) player moves slower on the platform than on the ground and there is jittering that’s why I made platform kinematic rb

Can someone tell me why player not moves with platform when both uses physics? And how to fix this

Thanks

The player needs to be parented to the platform onCollisionEnter and unparented onCollisionExit. Respond if you need more help than that.
This script goes on the player.

    private void OnCollisionEnter2D(Collision2D hitObject)
    	{
    		if (hitObject.gameObject.tag == ("FallingPlatforms"))
    		{
    			transform.parent = hitObject.transform;
    		}
    	}
    
    	private void OnCollisionExit2D(Collision2D collision)
    	{
    		if (collision.gameObject.tag == ("FallingPlatforms"))
    		{
    			transform.parent = null;
    		}
    	}

Player rigidbody is dynamic. Moving platform is kinematic. Both SleepingMode is start Awake and CollisionDetection is Continuous. I just tried this and it works perfectly. @kole_dole

If parenting does not work try calculating the offset so in fixedupdate make a vector2 offset = new vector2( player,transform.position.x- platform.transform.position.x,0)
That will give you the offset to do
rb.MovePosition((player.transform.position + offset)*time.fixeddeltatime). I’m assuming the rigidbody is the players and that this script would be attatched to the play. On collision enter you would set a bool isOnPlatform to true and on collision exit set it false then only run the above code while isOnPlatform is true. @kole_dole