How to make deforming vehicle tracks

Introduction

I recently wrote up a private message to another DevForum user that contained basically this same tutorial about how to make working vehicle tracks (think like on a tank) that deform with terrain. I thought I would publicly share it here too since I’ve only seen a few other people do it. The method I’m about to share should end up looking like the tracks in Armored Patrol. There are probably multiple ways to go about doing this, but this is what works for me.

Suspension Setup

The first thing you need to get right is to set up the suspension for the wheels in the correct way. Here’s a really bad diagram of how mine looks: image
If you need more help with that, I modeled it after the cars in this thread: [Update] Constraint Chassis

After you have the suspension working correctly and the vehicle can drive on its own, it’s time to connect the tracks. The tracks have collisions turned off. Here’s a picture of mine:

Track Setup

To achieve the effect, the tracks are not linked directly to each other with hinges. Between each segment are parts, which are connected to the tracks with hinges. I’ll be calling these parts ‘inbetween parts’ for the remainder of this thread. It’s hard to put in words, so it’s easier to show with another poorly drawn diagram:


You’ll need an intersection of tracks for each interior wheel of the vehicle. This is so that an inbetween part can be directly under each axle. In my case, my vehicle only has 3 wheels so I only needed 2 track segments and 3 inbetween parts.

Linking to Suspension

Once you get the tracks set up, it’s time to attach them to the vehicle and make them actually deform. The best way that I found without any scripting is to use an AlignPosition and AlignOrientation constraint with RigidityEnabled set to true.

Attachment0 of each should be set to an attachment in the middle of the inbetween part, and Attachment1 should be set to an attachment on the axle part. This can also be kind of hard to visualize with just text, so here’s yet another poorly drawn diagram:


The blue dots represent the positions of the attachments. Basically, the Axle part has an attachment that has a position offset such that it’s in the same WorldPosition as the attachment in its corresponding inbetween part. You’ll need an AlignPosition and AlignOrientation for each inbetween part, with Attachment0 of each set to the inbetween part’s attachment and Attachment1 set to the corresponding axle’s offsetted attachment.

Conclusion

If you set everything up correctly, you should be done! Here’s the end effect:
https://gyazo.com/991938d4d295c25d0217f08ebd45f2f4

I hope can help anyone who is looking to achieve this effect. It took a lot of testing and such to figure this out.

Disclaimer

This method is now slightly outdated. Mesh deformation in Roblox now allows for a more standard approach (at least in regards to how games in other engines do it). I have that working, and here’s what it looks like with a skinned mesh:
https://gyazo.com/22be2054baaa4d73999940de32feeab3

File

The included drive script is not good but it’s just meant to work, and it does. You’ll have to make your own script to actually drive the vehicle.
tankupdated.rbxm (15.3 KB)

97 Likes

This is a great technique!
Got a notif that my post was linked here, but its been crossed out. Was there actually not an issue related to sleep here? Or is there still an unsolved sleep issue?

8 Likes

I crossed it out because the changes went live as indicated on that thread. The changes did indeed fix an issue, thanks for working on it!

2 Likes

Um is there a tutorial to make this? it confused to me.

3 Likes

is there a chance we could get a model for the tank track setup you made? just so we can see how it works in studio

Yeah sure, I probably should have included one in the OP anyway.

The drive script included isn’t good but it works.

tankupdated.rbxm (15.3 KB)

2 Likes

Hey! The drive script included doesn’t seem to be working. Just wanted to give a heads up! I am getting a Network Ownership error on line 7 even though none of the parts are anchored. I basically just commented everything to due with the random ownership function to make it work.

Yeah that part was for something else I was experimenting with at the time. Thanks for the heads up.

The files have been fixed.

Hey @vastqud. I was hoping you could provide me with how you made the deforming tracks using the mesh deforming method. Thanks!

Sorry for the delayed response, I’ve been locked out of the dev forum for about a month now and only just got back in.

Anyway, the hard part is making the mesh itself. The mesh has to have a bone under each wheel and also be weight painted so that it deforms more near the bone. I can’t give any instructions on how to do this as I didn’t make the mesh and I also know nothing about 3D modeling. Scripting the mesh deformation is really easy, just update the position of the bones to the position just beneath each wheel.

2 Likes

ok but how would i make the tank threads rotate around using mesh deformation

When you see tracks “rotating around” in games they’re not actually moving. It’s a realistic texture being scrolled.

Because of the way textures are applied to the normals of meshes in Roblox, you’d have to split the track into two or more sections (top and bottom). Then apply textures to each face and animate them per frame depending on the speed of the vehicle.

Sorry for the bump.

I’m wondering, why do you need to have the actual mover script in a local script that you clone into the player’s GUI? I tried it out with a normal script and it works. Regarding network ownership, you can do that in a regular script as well. Am I missing something?

You don’t and you probably shouldn’t. I said in the OP that the drive script is horribly put together and severely outdated. You’ll have to make your own system to actually drive the vehicle; this post was only about the tracks themselves.

On the topic, you should probably be handling driving on the client (which is why the original implementation is cloning a LocalScript). The server shouldn’t be responding to user input. The client can manipulate the physics of their own vehicle (such as the angular velocity of the wheels) as long as they have network ownership of it, which they always should.