When two Rigidbodys collide, the hitted one goes crazy

Im just working for the first time with Rigidbodys and i have an problem.

When i pickup an object (cube for example) and i hit an other cube or car, they could easily be pushed away.
The mass from the cube is about 10 and the car’s one is about 1500.
I use the CharacterController Component to move my Player and when i pickup the cube, i put it under my camera, so i can move it.

Here is an example as gif: GIPHY - Be Animated

Can you set the rigid body of your grabbed object to “kinematic” while it is being grabbed/parented to the player?

It’s kinematic and gravity is disabled.
And i changed the code now, so it’s not anymore under my camera and i move it with rigidbody.MovePosition()
But doesnt change anything.

That’s because the cube hits the WheelCollider, not the car’s collider. The WheelCollider tend to do such crazy things when they collide with anything. You should “inflate” your car’s collider so the WheelColliders are inside the car’s collider. Thus, next time you will hit the car’s collider instead of the WheelCollider.

This is simply because you’re not allowing the “hitted object” to push back. By making it kinematic, the cube being held is basically immune to that “equal and opposite reaction”. Soooo, you’re basically forcing an unmovable object into a movable object. The movable object must move out of the way, and it can’t do anything about it… no matter how much mass it has. You are moving the cube, not the physics engine.

Tell me, what should happen when you push the cube into the car?
Should the cube stay locked in your hands? Then the car must move out of the way.
Should the cube be pushed back? Then it cannot be kinematic.

To let the cube be pushed around while you’re carrying it, you’ll need to let the rigidbody’s velocity carry it there. This lets the physics engine move both the cube and the car. And the physics engine knows that the cube isn’t massive enough to move the car without a lot of force behind it, unlike MovePosition which tells the physics engine, “Hey, put this thing at this spot” and the physics engine has to move everything out of the way to make it work!

To do that you can simply use Rigidbody.AddForce to “nudge” the cube toward your “hand” every FixedUpdate.

Vector3 nudge = (hand.transform.position - transform.position) / 42.0f;  // Gets weaker when closer.
rigidbody.AddForce(nudge, ForceMode.Impulse);
1 Like

I don’t know where are you right now and how are you doing but you are a beautiful person and you deserve the best in your life, your explanation saved me a lot of pain and nightmares.