- Home /
Flip over car after tips over?
Hi i am wondering if there is some kind of function to make a car flip over after it has turned on its side, such as in gta5, i have a terrain in my game so areas get bumpy and the car flips over often, if you could help me with this i would be very greatful Thanks in advanced
Answer by AlwaysSunny · Mar 23, 2015 at 08:50 AM
I recall that in GTA games, if your car-like-vehicle is tipped over about 90 degrees, (e.g. passenger doors are against the ground), some "magic physics" kicks in that will help the vehicle right itself. Is that what you're talking about?
Assuming that's what you want, I imagine there's a routine to check whether all tires are grounded, as well as a check for an orientation which represents being "on its side", and perhaps also a check to see if the vehicle as a whole is grounded. If the tires check fails and the other two are true, you apply your magic function.
This could simply be a subtle AddForceAtPoint to nudge the car in a way that would produce a rotation towards a Y-up orientation. The code shouldn't be terribly complicated if you leverage Unity's many convenience functions for 3D math.