Procedural Tank Tracks
Features:
- Generate Tank Tracks from Wheel Layout
- Easy and Fast setup
- LOD System
- Client Side only
Showcase:
Usage:
Heres a script Example on how to use it:
--Local Script
local TrackRenderer = require(game.ReplicatedStorage.Modules.TrackRenderer)
local tracksettings = TrackRenderer.newsettings() --Create Settings
tracksettings.TrackLength = 1 --Determines the Length of each Length of the Tread
tracksettings.TrackModel = game.ReplicatedStorage.Tracks.SimpleTrack --The Model to use
tracksettings.ParallelLua = false --use Seperate Actor and Script for each Tracks (Delays)
tracksettings.LowDetailPartWidth = 3 --Set the Width of the Part
tracksettings.LowDetailPartHeight = 0.3 --Set the Height of the Part
tracksettings.MiddleTrack = nil --place parts in between the treads
local track = TrackRenderer.new(tracksettings, v:GetChildren()) --track Constructor
track:Render() --Render the Track
track:SetSpeed(0.05) --Sets the Speed (In Studs/s)
Wheel Layout Setup:
we have to name the wheels numerically so the code knows which wheel to use.
The direction in which the Order follows must always have the Top be facing the Desired direction and the Bottom be opposite.
and we must add “_curve” to let the code know that the wheels “curves” around, in this case its 2. 4, 1, 5.
example wheel: Wheels.rbxm (4.3 KB)
API:
TrackRenderer.newsettings(): TrackSettings
Returns a TrackSettings which would later be passed on to the TrackRenderer Constructor
- Properties:
TrackSettings = {
TrackModel: Instance,
TrackLength: number,
ParallelLua: boolean,
LowDetailPartWidth: number,
LowDetailPartHeight: number,
MiddleTrack: Instance,
}
-
TrackModel: Instance
The Model or Part to use -
TrackLength: Number
The Length of each Tread -
ParallelLua: boolean
Creates an Actor just for that Track, allows for Parallel luau -
LowDetailPartWidth: number
The Width of the Low Detail part -
LowDetailPartHeight: number
The Height of the Low Detail part -
MiddleTrack: Instance
Places a Different set of Treads in between the Original Treads
TrackRenderer.new(settings: TrackSettings, wheels: {Instance}): Track
Creates a new Track Object with the Settings from the TrackSettings and the Table of wheels
Methods
-
track:SetSpeed(number)
Sets the Speed. -
track:SetLODDistance(number)
Set s the distance where the LOD will activate -
track:Render()
Renders the Track -
track:StopRendering()
Stops Rendering the Track -
track:Destroy()
Destroys the Track
Properties
track.Wheels(Read-Only)
The wheels currently used by the track (Includes the Main Part).
Installation:
you can either get it from:
or download the showcase place
showcase.rbxl (95.1 KB)
