- Home /
Tank wheels control
Hi everyone,
I want to use a very simple car setup with wheel coliders but the steering should be done by stopping (or reversing) the motorTorque of the wheel colliders on one side like an excavator.
I use this to add torque to wheels;
frontWheel.motorTorque = 45 * acc;
backWheel.motorTorque = 45 * acc;
and tried this instead of "steerAngle" from documentation for default car setups:
frontWheel.motorTorque = -40 * Input.GetAxis("Horizontal");
backWheel.motorTorque = -40 * Input.GetAxis("Horizontal");
I don't have to tell you that the behavior is less than expected : )
Also, regarding GetAxis - how do I know when I turn left or right? I'd prefer something mapped on my own keys, since I will have 2 types of turning ~ on the spot, where the vehicle won't move forward and normal turns, left or right, as I drive ahead.
Any hints or references to docs will be much appreciated. Thanks!
Answer by CallToAdventure · Apr 26, 2011 at 06:27 PM
The solution to this problem cannot be actually done with realistic (copying reality) controls without putting way too much physics at work. A tank has wheels but the traction is done with the, well, tracks (or treads). This part is the trickiest to achieve. Hence, I opted for a simpler solution: use wheels and wheel steering along with custom keys to turn on spot while using UV animation for tracks and simple rotation transforms for wheels matching the speed (actually, the parent's velocity) for a realistic effect. It's a bit of work to set up all wheels (20 for most tanks) and in particular bump/diffuse UV animation needs some digging in the documentation.
Answer by Jean-Fabre · Apr 18, 2011 at 02:09 PM
Hi,
I would actually use cylinders and control it via a configurable joint and let the friction do the rest.
You can view an example of an excavator, which I think is the same as what you are trying to achieve. and here the related forum thread
It might not be totally how you want to control your system, but could be a good start.
Regards input, you'll have to roll your own algorithm to detect what exactly the user is trying to achieve.
Bye,
Jean