Has anyone already written a tank controller with physics based suspension and or tracks? The one in the vehicle pack is basically just a fancy car. I am looking for something that moves a bit more like a tank. I am pretty much only concerned with the code for the tanks movement, not any turret/weapon code etc. I have seen a few tank games around but I wasn’t sure if anyone was willing to part with it for free or for a small fee.
I haven’t gotten the suspension component of the wheel collider to work properly, so no comments there.
A tank steers by varying the power applied to the left vs right tracks. A car steers by apply power to one or both pairs of wheels.
A tank has – in effect – lots of wheels, and they all get power.
A car generally has four wheels, and either powers the front or rear pair, or all four, or diverts power to whichever wheels have traction.
thats the problem as I see it is that there are several wheels that touch the ground only via the track. I am not sure how to effectively simulate this.
Once you start getting the suspension involved it becomes even more complex. The problem is if you don’t the tank track mesh just ends up going through terrain/colliders and looks odd.
My point is the only real differences are (a) steering, (b) all wheel drive, and (c) number of wheels.
The way suspension works (or doesn’t) for a car is the same as for a tank – just more wheels. I’ve never been able to get suspension to work properly at all, and when I asked I was told it was broken (it may have been fixed since).
Steering is easy – just steer by varying torque rather than rotating wheels.
All wheel drive is a bit trickier: as far as I understand it if you drive twice as many wheels you apply half as much torque per wheel to get the same acceleration – EXCEPT when I do this with Unity’s wheel colliders I get far inferior performance.
Not really accurate. The track needs to deform against the terrain or it looks phony. Using wheel colliders will give you the motion you want, but you still end up with tracks that dont deform against the terrain.
Have you ever completed your tank with tracks?
I am looking for a way to create convincing(physics based) tracks on the tank. It would really help if you could share some of your findings on this subject.
Perhaps a wheel collider with a “chain” of tank track meshes?
A chain of track segments would probably work quite well, but a wheel collider is really just a raycast and so has no physical volume. You would want to slide the tracks around the edge of a capsule collider or maybe a simple mesh collider to get the right effect.
And this method takes a while to construct and debug properly, and is fairly processor intensive compared to faking it.
At one point I wanted to make a functional tracked vehicle realistically, but I ran into the difficulties of placing the tracks properly on the vehicle.
If you have ever played a major title with tracked vehicles, you will know that they deliberately avoid this issue. All tracks are done using an animation of the track rotating, and raycast colliders for movement. Ex Halo, the Scorpion has tracks without suspension that simply animate rotation and move separately.
Not to say that the realistic method isn’t possible or practical, but that it is difficult to implement properly. If you ever get this working, please post a demo and maybe a package for us to see.
I almost had one working once, if i remember correctly i modeled it and imported it as a single mesh for each tred and wheel then linked them together with joints. if you dont have your model tight it will sag at game time, but after foolin with the joint strenght and physics mat, and of course rigidbodies(what else)oh the wheels were powered by script. problems i had, was the joints would not hold. I tried the differend kind of settings, hated to scrap the project, but realized, it was just over my head. :? But it was kind of worked til the track touched the ground(was spinning in the air just fine) then it would fall apart. :idea:
There is a tank demo game in the showcase that is pretty cool(may have to look for it) just tank movement and no tracks visible.
Hope this helped