Hey all, I have an idea for doing tank tracks, graphically that is, not a physics simulation of that.
I’ve been working on the next iteration of my tank models for the game i’m making(time to take a bigger leap out of greyboxing), I was wondering how best to get the appearance of the tracks moving, at first I was considering using one of them skinned mesh renderers, but then I had an idea - why not just make the texture go round and round with the shader? sounds like a lot less overhead, and now thanks to shader graph it’s trivial task.
What I’ve done so far is make a “model” tank for testing purposes where the area where the tracks is just flat and inside shader graph make the seamless texture loop in regards to the speed of the tank, couldn’t be simpler - knocked out everything from idea to prototype in less then 10 minutes, yay me.
*video to show what I did at the end of the post
now i’m facing a few problems, the first I have an idea on how to deal with but would like a better suggestion.
-
we have two tracks, each with it’s own speed (unless the tank is going in a straight line or is stopped) - how would I achieve that with the same material? I believe i can use one side for each track and let them behave differently with masks and all that jazz but it’s a little more then i’m comfortable with shader at the moment.
I can get around it with two materials (one for each track), but I don’t like slapping on extra materials(or extra anything) where not needed, which is what I think I’m gonna do… -
how to actually know how fast to loop it? it’s gonna depend on variables like the length of the track (if we assume tracks are covering the entire length or width of the UV), one loop can equate to different distances.
The track length is not a really problematic, can just feed each tank a value at editor time, just an example.
what I’m really stumped (that somewhat relates to the loop speed) with is how to derive/extrapolate the difference in speed for each track from the speed of the tank, the tanks are moved kinematiclly by me so I have all the needed information and then some - but what’s the equation?
I think all I need is ‘currentSpeed’ (the speed the tank is moving, -maxSpeed to maxSpeed), ‘currentTurn’( -1 to 1, how “hard” are we turning to what side - feel free to suggest a better name, haha) and just apply to each track (ignoring the first problem atm) individually using somekind of dot product to modify them.
But I’m just dumb struck with this.
The distance of 7.4922 I have Is from the edge length blender gave me, it’s almost perfect.
One other thing I don’t know how to deal with is the “tearing” I get when I change value, I know it’s caused by multiplying time with moveSpeed, but how am I to deal with it, do it differently or add somekind of filter to it?
Thanks for the read.
*some tearing on the tracks from face to face, It’s just the quick and sloppy modelling & UV. I hope, heh…