Constant force cancellation if not on ground

Hello,

I have a car object with a constant force of -300 applied to force.y. This is there to prevent my car from flipping because I move it using addForce. The side effect is that the car is glued to the ground. I don’t like it that way because I would like it to fly up when driving over ramps, or at least not look so bad while driving on hills.

Is there a way in which I can cancel the force as soon as there is a change in angle representing a hill or something? What I mean is that I can’t even drive up hills as I get pushed back down straight away.

Does anybody know a way of achieving this? I tried centering the mass on my car with some values, but something isn’t quite right.

To stop the car - or any object - from rotating on certain axis, you can tick the Freeze Rotations on whichever angles in the Rigidbody component that is attached to the object, presuming that object has a Rigidbody on it.

Hi.

I found a solution to my problem. I had to find the exact bottom center of my car and center its mass there. I set the position of the car to

transform.position(new Vector(0, 0, 0)) 

so that it matches its parent’s position. Then I centered the mass to new Vector3(0, 0, 0). I also removed the constant force because it is not needed any more.