How let rigidbody follow other animate object?

Hi~

I’m writing my character controller.
The character used rigidbody.
Now it can moving around by ADSW.

Here have a floating board moving at its X axis. The barod has Rigidbody(is Kinematic)

The question is:
How let the character follow the moving board?

Update 1-

I have a idea
if(isGrounded && collidedObj is rigidbody)
{
character.rigidbody.MovePosition( collidedObj.transform.postion);
}
Let me have a try~ :slight_smile:

Update 2
I just tested my idea.
Check the character’s feet whether conllided with the layer mask(contain the moving board).
If yes, set character’s position equal the moving board.

if (axisInput.magnitude == 0 && isFollow)
{
     rb.MovePosition(target.position);
}

But, I need a offset(character and the board).
Character on center of the board now.

I tried this:
rb.MovePosition(target.position + (target.position - rb.position));

Dosen’t work. How fix this?

I know this is a stupid method, If you have any idea plz let me know. Thank you!

Update 3
Let me ask another question :stuck_out_tongue:
Forget the character.
Here have a cube and a moving board.
The cube is rigidbody,use gravity.
The board is rigidbody, unuse gravity, kinematic is enabled.

Put the cube above at the board.
Play game.
Cube drop on the board, but it not follow moving.

How can I do that?

If you have an idea, try it and see if it works!

To have more controll over the smoothness you could lerp or smoothdamp the position (or difference between the board pos and player pos)