# Dynamic tank tracks - Proof of concept

So i’ve been working of a way of having the portion of a tanks tracks that touch the ground be able to follow the contours of what it’s touching. My thoughts on how to do this are…

1. Have a mesh object that has many edge loops.
2. Create an array of bones spaced evenly along the mesh.
3. Weight the bones to the mesh.
4. Make the Bones a Rigidbody and give them sphere colliders.

4a. (Alternate method untested idea) Use Raycast to get distance to the ground.

Here are the results for the Rigidbody method.

Thoughts, ideas, suggestions are more than welcome, as i am only just now starting to explore this problem i am curious as to what you think, or any different way of solving this.

Looks like a solid idea, but my initial question is how do you plan to handle the full loop of the track?
I figure you’d need something inside the loop to keep it open, but would the top of the loop not be causing pointless collision checks while not touching the ground?

The track rotation will be handled with texture offsets. The geometry will not rotate. This is just to get the illusion that the track is conforming to the ground.

Would Jake’s rope script offer any possibilities?

I’m making a tanksimulator and used your alernative 4a with very good results.

Here is an old example,it has some now fixed bugs.But because the game now is a network multiplayer I didn’t have the time to convert it back to a singleplayer again just to show an example.
The biggest problem was how to make the treads not deform too much when the wheels had no contact with the ground ( the example doesn’t have that fix so the treads extend forever if you drive out of bounds).

http://dl.dropbox.com/u/20727661/TestTiger/WebPlayer/WebPlayer.html

Drive with the arrowkeys
U,I,O for different cams
A and D to turn the turret
W and S to move the gun
SPACE for shooting.

Hey that’s pretty cool. Indeed the tank tread movement looks very realistic. I hate to nitpick but I have a small suggestion, in the version you posted it seems like you can’t turn the tank while it’s not moving forward. Real tanks do this quite well by moving one tread in reverse while the other moves forward, it certainly helps getting around tight areas.

Yes,real tanks post-1945 all have the ability to turn on the spot.

I know that German tank-ace Michael Wittman used this technique to quickly change target.

The Tigertank couldn’t even fire when driving without damage to the turretring because of the turrets weight and the forces of recoil.
The gearbox frequently broke down even when driving on roads because it was underdimensioned for the 56.9 tonnes the Tiger weighed in at.
That’s German engineering for you joking.

EDIT: Older tanks pre-1945 could put brake on just one tread (the German towerless StuG used this technique to aim its gun) and turn that way,but they couldn’t drive one tread in a opposing direction like modern tanks can.
I want to reduce the Tigers aimingspeed so the Firefly can have a chance,otherwise no one will ever play on the “Good guys” side.

Larsa334, Nice demo i like what you’ve got. What was your method for the track rotation, Just have the texture drive the animation to make it look as the track is moving?

In the post above you mentioned that the track will extend for ever if the conditions are right. So i’m sure you probably fixed this but if not you could limit the amount the track drops by limiting how far from the Raycast origin it is allowed to move. You can also limit how far the Ray can cast out too.

It is all done with textureoffsets.I used a diffuse detail material on each track so the same value is fed to both base and detail-offset.

Yes,I have fixed that bug.

The raycast in the middle of the wheel moves both the treadbone and the wheel so that the whole package stays on their separate offsetvalues from the ground.

Then the upper “stopper”-raycast have a limiting value that determines when both the wheel and tread have reached its lowest allowed Y-value.
The two drivewheels on each side is naturally connected to the tanks body and don’thave raycasts at all.

I have made a new thread in showcase:

I have also uploaded a much newer build of the demo there too.

I thought a lot about what Antitheory said about rotating on the spot!

The solution I came up with to make it “historically correct” was to make one separate pivotpoint per track.

I then used transform.RotateAround to rotate the tank around them.

Please try it out in the webplayer and say what you think.

There is a little problem when the two rotationmodes (stopped and moving) switches,but I think I can tweak the variables to make it disappear.
Maybe use lerp…

http://dl.dropbox.com/u/20727661/NetTiger/WebPlayer/WebPlayer.html

I haven’t had the time to fix the UVoffsets when rotating yet.

Here is a picture of where I placed the two pivotpoints:

If you were going that route, you would add a single raycast and use the normal of the hit to develop the rotation of the tred.

Interesting!I send the tanks velocity as serialized info over the network to turn the wheels and offset the treads.I tried to use rigibodyvelocity to reconstruct the speed but it worked very poorly.

I have to look into how this works.

I implemented some nice tracks for one of my tank projects. It was in Lightwave but the principles could be applied to Unity.

Closed loop of “cloth” made up of polygon lines, with the friction of the front/rear drive wheels moving it. The hard links were orientated along the length. With gravity and collision with the ground/rollers, it looked pretty realistic.

Shame I lost all that stuff in a HD meltdown.
This was the tank. http://steamrolled-media.net46.net/portfolio/CGI/Misc/Tank_mkIV_Still.jpg

Your tank is a male tank and mine is female.Maybe we’ll let them meet sometime?Who knows what would be the result of such a meeting?!?

Tool for simulation of the tank

Demo project
dl.dropbox.com/u/13974857/Tank.html

Tank Demo Video

Tank Video Tutorial

Tank Track Simulator

• Based on the component Physics / Hinge Joint
• Well controlled on uneven terrain
• The tracks are created from individual pieces, that look very realistic
• Track simulation not fully based on physics, because of this, does not require a lot of computational memory.
• Turret also can controlled

Another option for tank tracks that is very fast and works very well over terrain with a little extra scripting, ie simple raycast from the knot positions.