Download the proof-of-concept DEMO (3,6 MBytes, needs OpenGL)
Important : PLEASE read the included readme.txt before starting the demo and/or complaining in this thread.
Also note, when using a gamepad, it's possible that you need to change the axes for controlling the tracks, you'll have to test that out.
If it won't work for your gamepad, just use the keyboard controls.
3rd video (14th March) showing the almost finished version (WMV format, ~60 MBytes, 5:40 min)
Second video showing functional turret (~11 MBytes, 1:30min)
Download the video (~3 Minutes, 35 MBytes, WMV)
But some days ago I decided to give it another shot (finally got more time to do coding) and now I got a tracked tank that's almost working perfect. As with the old demo I'm still using the contact process callback to simulate an "inverted" conveyor belt material for the tracks, something that's very easy to implement and should allow for dozens of tanks at good framerates. A lot of people try to implement tanks by using dozens of wheels to fake tracks, but that's not always working as supposed and it's very slow.
There was a rather long discussion back in that old thread, so I won't be retelling the whole story here, but the basic things you'll have to take care of are :
- Use the contact process callback for the tracks (apply material to the tracks only)
- In that callback, rotate the contact's tangent so that it points along the "floor" of the track (e.g. if you move on the z-axis, rotate it to 0/0/1)
- Set tangent acceleration, this depends on how you implement it, I calculate it using the tank's velocity along the z-axis and the current accelerator value of the track (this way you can tell how fast each track should move)
- Important :Model the tracks so that they generate even contacts. The tank from the old demo had a slope on the track's floor, whereas the new one (which I modeled for the game I'm working on currently) has a more flat track floor and therefore contact generation is more even.
- Important :Get your center of mass right. Sounds very basic, but if you e.g. include a long gun into your compound/convex hull, it's very likely that the COM is offset to the front of the tank and this will make especially rotating very bumpy.Setting the COM is crucial, so take your time to adjust this.
- Hint :Don't make the tracks rigid. That's what I did in the beginning (and the old demo), as this makes your tank move like it's made out of one block of metal rather than it should be. Right now I'm testing (you can see it in the debug display at the end of the video) with a hinge joint that tilts some degrees forwards and backwards. Not perfect, but very close to a real track in terms of movement. Next step could e.g. be to add a spring to that hinge to make it look more natural. But this is something that you can try out yourselves, maybe a slider with some freedom and a spring would be a nice alternative too.
Another idea would be to make the track out of several hulls and use sliders with springs for those hulls, that should give a very nice driving experience. - Turret :Use a custom hinge joint, that supports rotations beyond 180° and 180°. See Julio's source for it here and simply add an angular row at the end (with the same pin direction as the hinge) that changes the turret's rotation to match the currently manual set one (CurrRotation-ManualRotatio). This gives you a turret that sticks to the tanks movement and rotation (they way it's supposed) but that can be freely rotated manually.
So as you can see there is not much magic behind creating a tracked tank, and hopefully this thread will help people out there get tanks into their games.