- Home /
Car moves only when the wheels have no colliders
So far in my project right now I have been trying to create a driving game with my own car model using the unity car tutorial. At the moment I am using the wheels from the car model from the tutorial (because I was having problems with the ones I had modeled) but I am still running into problems. The problem right now is that when the rear wheels have no colliders I can move the car and everything goes normally (aside from the wheels going through the ground because they have no colliders), and when have colliders the nothing happens and the car does not move and the wheels do not rotate(also I can hear the sound affect of the car diving).
Does anyone know what could be happening?
Thanks.
Answer by Edy · Nov 30, 2010 at 01:13 AM
The Car Tutorial is a bad starting point, IMHO. The car controller script (Car.js) is obfuscated and specifically designed to work in this exact project, not as generic vehicle control script one can reuse or learn from. It doesn't use the WheelColliders from the model, but it creates its own GameObjects and WheelColliders at runtime! So its very difficult to keep track on what and how the script does anything.
What seems to be happening in your case is that when your model has no WheelColliders, the ones created inside the script work properly moving the car. When you add your own WheelColliders to the model, then they are surely 'lifting' the car so the runtime WheelColliders don't reach the ground - thus the sound and everything else works, but the car doesn't move.
My recommendation is to follow this tutorial instead:
http://carpe.com.au/slawia/2009/08/unity-wheel-collider-introduction/
If you need something working to start from, you may check out my vehicle physics here:
http://forum.unity3d.com/threads/47366-New-Unity-Car-Tutorial-GTA4-Vehicle-Replica-Project-4050?p=414127&viewfull=1#post414127
Answer by spinaljack · Sep 19, 2010 at 08:45 PM
The WheelColliders are actually raycasts, the don't spin or have any sort of size or shape in the physics engine. All they do is produce force proportional to the friction value and distance to the floor. (like a hovercraft or jet engine)
If you put a collider on the wheel model it'll either block the ray casts or get stuck on things preventing the car from moving.
What you need to do is set a higher suspension height and radius on the wheel colliders so that the model appears to be over the ground.
Your answer
Follow this Question
Related Questions
Wheel collider in the air problem 0 Answers
Alternate Physics - Car tutorial - how to avoid car slipping? help please 1 Answer
Can i use Unity' tutorial car in my game? 2 Answers
Tire deformation? 0 Answers
2 Scripting Errors I need help fixing!! 3 Answers