Hey there! I have made a physics based velocity train and it works like a charm and goes all around the track however sometimes it decides to slip off around the corner and go on its own route off the track. If somebody could get to me that would be great and I will send my code in this post. It is probably something simple but im not that great with physics haha. Would putting a force downwards stop it or what would?
Try something like that. That just a template.
local train = game.Workspace.Train
local track = game.Workspace.Track
local forceStrength = 50
local function applyForce()
local trainPosition = train.Position - track.Position
local distance = trainPosition.Magnitude
local forceDirection = -trainPosition.Unit
local force = forceDirection * forceStrength
train.BodyForce.Force = force
end
game:GetService("RunService").Heartbeat:Connect(applyForce)
Hey, thank you but how would I implement the tracks to be a model? My tracks are models not just a singular part?
That i don’t know make function to get the track at proximity i don’t know.
You can make a model a single part via the union operation.
https://create.roblox.com/docs/reference/engine/classes/UnionOperation
What if I use mesh parts though?
Sorry but i cant think of way that i know how to do that. You might be able to use a for loop?
https://create.roblox.com/docs/education/coding-4/intro-to-for-loops
https://create.roblox.com/docs/education/coding-5/pairs-and-ipairs
If you would like to look at my code for my project you can get it here: Dropbox - Error
Thanks!
-Grant