How to offset a material UV coordinate according to velocity?

I have a tank ( Vigilante @ marketplace) with tracks that are animated by offseting the UVs in the X direction.

The issue is, I can’t think of a simple way to offset the UVs at a speed relative to the vehicle’s velocity.

I also need to make sure to offset in the opposite direction if the vehicle is moving backwards.

This is what I could think of so far, but it’s not perfect. I run “Update Track Positions” on tick.

Any help?

Found a better way to do this. Had to scrap the Vigilante’s way of track movement and used a Panner node in the material. Adjusted my tick code likewise.


Works better, and is probably more optimized, the track snapping at the end is due to the branch node in the beginning.

Yea - you’ve pretty much solved it.

You might need to extend the material to have its UV scale taken into account if you have vehicles with scaled up/down track textures and you probably need to get the wheel speed more precisely and get rid of the branch to avoid the slipping but other than that - it seems pretty much on point.

Is this still standing question?

1 Like

Would you happen to know any other way to get a more precise wheel speed?

First sorry for my mad paint skillz :wink:


LTV = S + d * R
RTV = S - d * R
where:

  • LTV is the left track velocity
  • RTV is the right track velocity
  • S is the speed of the vehicle forward in units per second
  • R is the current turning speed in radians per second (if you have it in degrees just use this formula rad = deg * π / 180)
  • d is the distance between the track and the center line of the vehicle or half the distance between the two tracks in units

This will give you the absolute speed of the tracks in units per second. Which one is + and which one is - depends on which direction R is positive and when it’s negative.

Now once you get the speed of the track and how big your texture is in real units you can make the track texture move with exactly the correct speed.

Now the wheel turns like so:
WV = LTV / r
where:

  • WV is the wheel velocity in radians per second (you can divide by 2π to get rounds per second)
  • LTV is the velocity of the track in units per second
  • r is the radius of the wheel in units

These are independent of the position of the wheel but are different for each wheel size and each track. (as the tracks move independently from each other when turning)

I hope this helps.

PS. A small correction - in the diagram (and in real life) the tracks should move in the opposite direction of the direction of travel so probably you have to use -S… Still it should give you enough insight on how to calculate it.

1 Like

That’s some mad maths skills too :smiley:

I’ll dissect this when I get to my desk and see if I can implement this.