Sudashi
Sudashi

Reputation: 11

Unity: Rigidbody moves on a moving Rigidbody

I am making a game in Unity where one player can drive a truck and another player can move inside that truck. When the player enters the back of the truck I parent him to the truck so he moves with the driving truck. But as both are rigid bodies this gives me a bunch of problems as the player does not properly move with the truck (he drags across the floor, sinks, etc.).

My first idea was to create a clone of the truck and spawn a clone of the player as soon as the player enters the back. The second truck has no rigid body, only the colliders and the local position of the clone gets copied to the local position of the real player in the real truck. This somewhat works but creates a bunch of problems with the player move script, player look and Networking, so I was wondering if there is an easier way to do it.

Upvotes: 1

Views: 69

Answers (1)

CaptainDryVids
CaptainDryVids

Reputation: 1

Simply put the drag to 0 on both rigidbodies, that should do the trick.

Upvotes: -1

Related Questions