Offroad Speeder v02
July 17, 2012
I updated the version of the Speeder with the CarSmoothFollow Script from the Unity Wiki.
I also added detachable spoilers via the Hinge Joints (setting the Limits very narrow so that they don’t move by themselves). The Fixed Joints seemed a good idea at first but they wouldn’t keep still. So to prevent the spoilers from wobbeling around I used the Hinge Joints instead.
I also tweaked the physics a little bit more but without getting significantly better handling from the car…
Categorised in: Game development, Unity3D
8 Comments
Excellent blog! It’s so nice to find some help with vehicles physics in Unity. I’m currently working on a off road jeep simulator, and I’ve been having a lot of issues trying the truck not to turn over on a simple curve.
If you like we can help each other!
Thanks Luis, the easiest thing to do is (of course) to lower the center of mass of the vehicle, but don’t drop it below the ground plane as this will lead to strange handling in some cases and will make the car tip back up when it rolls over (which is only usefull if you really want it to behave that way)
What I’m doing right now is to reduce the sideways wheel friction curve so that the car starts to slide instead of tipping over. In most cases this should also look better but it will certainly require some testing and trying.
Yes, I lowered the Y of the mass to -1.5 and is more responsive now. However, still turn over while turning in a close curve.
I now the solution has to be with friction settings. But if you set sideways friction very sensitive, the car will drift while going straight. Maybe through code we can adjust those settings while applying vertical input.
I’ve been playing with the spring settings as well. With more spring distance and a higher spring and damper suspension, the car is less prone to turn over.
Soon i’ll upload my project to a website so you can see what i’m doing.
Usually the extremum value should take care of holding the car straight while moving only forward. The sideways motion while turning should be enough to let the asymptote value come into effect which should be low enough to let the vehicle drift nicely through the corner.
But I also have had difficulties with this because it is pretty hard to monitor which slip value is currently being applied to the wheel.
What you could do is to increase the sideways slip extremum while the wheels are pointing forward and to decrease these as soon as the wheels are turned into a corner. It’s not a great solution but may work good enough for your purpose.
I would be very happy if somebody could show a way to monitor all the physics values of the wheel colliders properly so that I can configure them properly.
Driving the speeder around is really a lot of fun! You could easily turn this into some type of alien shoot’em up game for iPhone/Android. J
This is the first time I’ve seen a vehicle done in Unity with visually working suspension arms. What did you use in Unity to connect the wheels to suspension arms, and the arms to the body? I’ve been trying all kinds of crazy things to no avail and I can’t find any other info on the Web. Can you help a brother out? Thanks!!
I’ve had several ideas for this but it’s been put on hold as long as there is this eradicate behaviour in certain situations that makes it pretty difficult to properly control the car. It may be a problem with the internal car physics engine but I haven’t had any time to further investigate.
The suspension arms are actually pretty simple. You add the struts to the body of the car. Their axis should be at the base where the strut is supposed to rotate around. Then you add empty game objects to the non-rotating part of the wheel (i.e. the wheel collider) at the position where the struts should end. Finally you add a script to each strut that rotates the strut so that it points directly towards the empty game object on the wheel collider. This can be done with the transform.LookAt() function.
There’s probably room for optimisation here but the basics work this way.
Got it! Thank you very much! I will share my attempt at it when it’s done. Cheers
Hi Lychesis,
Wow very cool car game. I made a simple car game for a school project last year. I did get an 8 so that’s cool. But after seeing your project I just want to make some improvement for fun, would not result in an higher grade but who cares ^^.
Any chance I could take a look at your car code? Would mean a lot to me. I will only use it to see how those hinge joints work. It would be really awesome 🙂