Any help with creating tank tracks like in MTC4

i assume they raycast each wheel’s position to the floor and then the distance is used to move each wheel.

something like that.

1 Like

bumping this, but i found this video, i think i could use this and find a way to export it to roblox studio,
any help with doing so would be amazing!

there’s couple of ways you can make good looking tank tracks, sorted from the most performance effective down to the least

  1. Use Beams, fold them into a 3D box… you can add textures and make it move!

  2. Mesh Deformation Tank Tracks, this’ll be more of a pain to do especially if you’re planning to make multiple tanks… but, it works!

  3. Use ALOT of math formulas, combine bezier curves and alot of other stuff… basically, animating and generating the Tank Tracks using purely math. This is what i did before, you can find the post. And, it’s great in performance. Ultimately, you can use ChatGPT to help you with it! Which i did, and it ended up working perfectly. Keep in mind though, you’ll need to be VERY DETAILED and SPECIFIC when you use ChatGPT! (like, specifically mention that it needs to be CFrame)

  4. Physics Constraints (self explanatory)

1 Like

hey, i checked your post and its really cool. i am looking forward to recreate it!, any help from you would be amazing!.


I already begun with some simple track generation and updating

but i don’t know how do i get some curves on the idler and drive sprocket wheels
uhhcurves
I am not really good at math and i have to rely on free resources very often

You’re doing amazing so far, and to make it curve, like i said! Use, bezier curves! Should be quite simple to learn in lua, and there’s alott of resources regarding that! When i have the time, I’ll check the script of my tank system and teach you^^

1 Like

hey!, i finally managed to add some curves to the treads


now i just need to find a way to have some parts moving, which i cant figure out how.
perhaps can you explain me how does your code move the parts?. thanks in advance

1 Like

you could always fake the movement with beams

1 Like

i messed up something in my code and now it does not look at the endposition of the segment
helpme

for j = 1, numofsegments do
		local tread = v[1][3][j]
		if tread then
		local values = value(i, j)
		local t1 = (j - 1) / numofsegments
		local t2 = j / numofsegments
					
		local startpos = att1.WorldPosition
		local endpos = att2.WorldPosition
					
		local P1 = startpos + (endpos - startpos) * t1
		local P2 = startpos + (endpos - startpos) * t2
	    local new = CFrame.new((P1 + P2) / 2) * 
        CFrame.Angles(att1.WorldCFrame:ToEulerAnglesXYZ())
					
		values[1] = tread
		values[2] = new
		values[3] = Vector3.new(xysize[1], xysize[2], (P2 - P1).Magnitude)
		
		table.insert(partstomodify, values)
	end
end

i accidentally sent this without finishing it.

so i tried by just added the lookat pos by the angle but it seems to not work when i try to rotate it in any angle.
perhaps i did something wrong?,

I believe the problem is here

CFrame.new((P1 + P2) / 2) * CFrame.Angles(att1.WorldCFrame:ToEulerAnglesXYZ())

CFrame.Angles needs Radians, and if I’m not mistaken, ToEularAnglesXYZ returns Degrees. To fix that, try using ToOrientation instead!

CFrame.new((P1 + P2) / 2) * CFrame.Angles(att1.WorldCFrame:ToOrientation())

Sorry for the lack of replies by the way, I was busy!

well tried that, seems to have no affect.
i tried with just

local new = CFrame.new((P1 + P2) / 2, endpos)

just have the part to look at the endpos and not have att1’s angle not affect it. it kind of works, but when i just roll it a little bit the treads does not follow

thats why i tried to have the treads copy the att1’s angle so that when it happens it follows along.
so i tried with
CFrame.new((P1 + P2) / 2, endpos) * CFrame.Angles(att1.WorldCFrame:ToOrientation())
but that still does not work because if i try to rotate it, it does this


if there was a way to have both looking at the endpos and att1’s angle and somehow combine them
it could be the fix

nvm i found the solution,
it was just local new = CFrame.lookAt(pos, P2, att1.WorldCFrame.UpVector)
just have it look at P2 and have it copy att1’s upvector if that what it supposed to do.
now i just need to find a way to actually move the treads or animate them

Hey! I actually made the tank tracks for MTC4 :slight_smile:

There are no bones or mesh deformation involved. It is actually seperate parts for all the track links, which are animated every frame. Lot of math involved to calculate the correct position and rotation for each track link. My implementation doesn’t have the best performance yet, still gotta work on that. What I did however was calculate the CFrames locally then transforming them to world CFrame using some anchor part in the tracks so rotation of tank is accounted for.

1 Like

what do you mean by “track links”?

each segment of the tracks.


notice the gaps between the sections.

1 Like

well i did it, i managed to make the tracks to move, all i did was lerp the tracks from att1 to the next att2 which is updated every frame after the list of points for the treads are updated, like this
local cf = startingatt.WorldCFrame:Lerp(nextatt.WorldCFrame, offset)
and have the offset added every frame

offset += script.Speed.Value
if offset > 1 then
	offset = 0
end

the code is very spaghetti but i’ll just clean it up later
now just 1 more to add which is to actually match up the speed of the tracks to studs per second (bascially the speed of the vehicle)

3 Likes

That looks sick man! Keep up the great work

1 Like

Yeah i wish i knew how to make these

1 Like

There are a few tanks with tracks in the toolbox. Reverse engineer a few and take a look at how that is done. I found 3 pretty good ways and picked the one I liked the best. After that I knew how to do this by heart. Mine used all motors and constraints, no code to it at all… other than motor speed.

Just saw your video … looks great!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.