Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Tires tracks

Recommended Posts

I do know an algorithm that will calculate the centre of rotation for the car.  You could use that centre of rotation and radius to then draw the decals in a circle, but I'm not sure how it will perform if the player is constantly changing directions.

An easier and more accurate way may be to grab each tire position and draw decals on the terrain at those locations.  I've not used decals before, how are you drawing the tracks so far?  If you show some code I may be able to help more.

Link to post
Share on other sites

An easier and more accurate way may be to grab each tire position and draw decals on the terrain at those locations.

Thx, yes that was my method but it is not 100%. Calculatoin should be a mix out of velocity and rotation but I can't get it complete in my mind.

I used a modified code from the decals used for the bullets tracks on walls. It runs ok if the car stays in a "normally predictable" line of drive but not if the car is suddenly sliding like in the gif.

[Sorry I had problems by uploading / deleting example video]


            local TirePos0=self.Tires[0]:GetPosition(true)
            local TirePos1=self.Tires[1]:GetPosition(true)
            local TirePos2=self.Tires[2]:GetPosition(true)
            local TirePos3=self.Tires[3]:GetPosition(true)

            local DecalPosY0=self.Terrain:GetElevation(TirePos0.x, TirePos0.z)
            local DecalNormal0=self.Terrain:GetNormal(TirePos0.x, TirePos0.z)
            local DecalPosY1=self.Terrain:GetElevation(TirePos1.x, TirePos1.z)
            local DecalNormal1=self.Terrain:GetNormal(TirePos1.x, TirePos1.z)
            local DecalPosY2=self.Terrain:GetElevation(TirePos2.x, TirePos2.z)
            local DecalNormal2=self.Terrain:GetNormal(TirePos2.x, TirePos2.z)
            local DecalPosY3=self.Terrain:GetElevation(TirePos3.x, TirePos3.z)
            local DecalNormal3=self.Terrain:GetNormal(TirePos3.x, TirePos3.z)

            local TireTrace0 = Decal:Create(self.TireTraceMat)
--            local TireTrace1 = TireTrace0:Instance()
            local TireTrace2 = TireTrace0:Instance()
            local TireTrace3 = TireTrace0:Instance()

--            TireTrace0:SetScript("Scripts/Objects/Effects/BulletMark.lua")
--            TireTrace1:SetScript("Scripts/Objects/Effects/BulletMark.lua")


            TireTrace2:SetPosition(TirePos2.x, DecalPosY2,TirePos2.z,true)
            TireTrace2:SetRotation(0,self.entity:GetRotation().y-((10+Vit_locale.x*3)* self.turning),0)    -- TOP VIRAGE GAUCHE cad 

            TireTrace3:SetPosition(TirePos3.x, DecalPosY3,TirePos3.z,true)
            TireTrace3:SetRotation(0,self.entity:GetRotation().y-((10+Vit_locale.x*3)* self.turning),0)

--    System:Print(math.abs(Vit_locale.x*20))

            local mat = TireTrace2:GetMatrix()
            mat[0] = mat[0]:Normalize() * 0.1--math.max(0.1, 0.2 * math.abs(Vit_locale.x))
            mat[1] = mat[1]:Normalize() * 0.1
            mat[2] = mat[2]:Normalize() * 0.2 * (self.vitesse/5)

            mat = TireTrace3:GetMatrix()
            mat[0] = mat[0]:Normalize() * 0.1
            mat[1] = mat[1]:Normalize() * 0.1
            mat[2] = mat[2]:Normalize() * 0.2 * (self.vitesse/5)

Link to post
Share on other sites

I think the issue above is that your placing a decal at the tire position and rotating it to that of the cars current angle (or the tires angle, I can't quite tell).

An approach I would try is to collect the points under the tires over time.  When you have the current point and the last point, you can draw a decal between them.  Every frame you can check the distance from each tire to the last point that tire was at.  When it is equal to the length of the decal, make a decal between those two points.  Place the decal at the first point and rotate toward the second point.  In my mind you should get something like this;


  • Like 1
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...