Jump to content

Tires tracks on the ground.


Marcousik

885 views

 Share

This  an entry for a new completed feature:

Wheels can leave a trace on the ground using decals.

Here is a bit code on how to make that work.

Quote

        local TracksEnabled = true

        if TracksEnabled == true and self.vitesse>1 and Time:GetCurrent()-self.TireTraceTimer>50 then

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


            local DecalPosY2=self.Terrain:GetElevation(TirePos2.x, TirePos2.z)
            local DecalPosY3=self.Terrain:GetElevation(TirePos3.x, TirePos3.z)
 


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

    
            TireTrace2:SetScript("Scripts/Objects/Effects/BulletMark.lua")
            TireTrace3:SetScript("Scripts/Objects/Effects/BulletMark.lua")

 

            TireTrace2:SetPosition(TirePos2.x, DecalPosY2-0.1,TirePos2.z,true)
            TireTrace2:AlignToVector(TireTrace2:GetPosition(true)-self.OldPosTireTrace2,1)
            self.OldPosTireTrace2=TireTrace2:GetPosition(true)

            TireTrace3:SetPosition(TirePos3.x, DecalPosY3-0.1,TirePos3.z,true)
            TireTrace3:AlignToVector(TireTrace3:GetPosition(true)-self.OldPosTireTrace3,1)
            self.OldPosTireTrace3=TireTrace3:GetPosition(true)

 

            local mat = TireTrace2:GetMatrix()
            mat[0] = mat[0]:Normalize() * 0.15
            mat[1] = mat[1]:Normalize() * 0.2 * (self.vitesse/5)
            mat[2] = mat[2]:Normalize() * 0.5 
            TireTrace2:SetMatrix(mat)

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


            self.TireTraceTimer=Time:GetCurrent()

        end

Here is how it returns ingame:

 

Edit 19.01.2022

First visual mud effect: 

 

 

Enjoy!

  • Like 3
 Share

1 Comment


Recommended Comments

Guest
Add a comment...

×   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...