2 rectangles, realistic collision on a side?

Hi,
I am trying to make a truck colliding with a small car. When the truck collides with the car, and the car is in front of the truck but slightly on the side, instead of rotating towards the left, it goes a little bit left then right and is being pushed on its transform.right. I would have expected the car to rotate at least 180° and to go backwards, even if it touches the truck again. I tried to play with mass, with the size of the collider box, …

Here is a gif :

3099115--234010--wrong_direction.gif

It’s not easy to follow you on what’s happening and what you want to achieve. Maybe a picture would help.

I edited my message.

could try Unity - Scripting API: Rigidbody.AddForceAtPosition

or physics materials, more bounciness?

Gif hard to follow too.

You could also try changing the centerOfMass.

Is the large block actually moving or are you just translating it from position to position? In other words, is its body moving under its own velocity / using Rigidbody.MovePosition. If you’re just repositioning it then it’s not moving through space so it’ll just become overlapped which will cause physics to only solve the overlap.

2 Likes

Yes great, thank you MelvMay it works now. I was using

transform.position += Vector3.forward*speed;

I now use this :

GetComponent<Rigidbody>().velocity = (Vector3.forward*speed) * 50;
1 Like