Hello Roblox,
I have recently decided to build a train game which uses a BodyVelocity to be able to move.
When building this, I have come to an issue. My train is not able to steer! (video)
https://i.imgur.com/9hgnRG3.mp4
Does anybody know how to fix this?
Here is my script:
local VehicleSeat = script.Parent.Parent.VehicleSeat
local Configuration = script.Parent.Parent.Configuration
VehicleSeat.MaxSpeed = Configuration.MaxSpeed.Value
while true do
if script.Parent.Speed.Value > 0 then
if VehicleSeat.Throttle >= 0.1 then
script.Parent.Speed.Value += 1
wait(0.5 / Configuration.Acceleration.Value)
script.Parent.Parent.Bottom.STEER.BodyVelocity.Velocity = VehicleSeat.CFrame.LookVector*(script.Parent.Speed.Value)
-- print("Accelerating, " .. script.Parent.Speed.Value)
elseif VehicleSeat.Throttle <= -0.1 then
script.Parent.Speed.Value -= 1
wait(1 / Configuration.Braking.Value)
script.Parent.Parent.Bottom.STEER.BodyVelocity.Velocity = VehicleSeat.CFrame.LookVector*(script.Parent.Speed.Value)
-- print("Braking, " .. script.Parent.Speed.Value)
elseif VehicleSeat.Throttle == 0 then
wait()
--print("Idle, " .. script.Parent.Speed.Value)
end
elseif script.Parent.Speed.Value <= 0 then
if VehicleSeat.Throttle >= 0.1 then
script.Parent.Speed.Value += 1
wait(0.5 / Configuration.Acceleration.Value)
script.Parent.Parent.Bottom.STEER.BodyVelocity.Velocity = script.Parent.Parent.Bottom.STEER.CFrame.LookVector*(script.Parent.Speed.Value)
-- print("Accelerating, " .. script.Parent.Speed.Value)
elseif VehicleSeat.Throttle <= -0.1 then
wait(0.5 / Configuration.Braking.Value)
-- print("Stationary braking, " .. script.Parent.Speed.Value)
elseif VehicleSeat.Throttle == 0 then
wait()
-- print("Idle, " .. script.Parent.Speed.Value)
end
end
end
4 Likes
I do not have any SpringConstraints, and my train runs on the track via a system which looks like this
2 Likes
Makeineer
(Makeineer)
September 27, 2021, 2:48pm
#4
Have you tried adding a floating layer to keep the parts down? You’d just need to turn off CanCollide for a small portion of your train car.
You might also try adding a half-sphere on the exterior of the track and simply welding it manually.
1 Like
Have you tried adding a floating layer to keep the parts down? You’d just need to turn off CanCollide for a small portion of your train car.
Could you please elaborate what you mean?
You might also try adding a half-sphere on the exterior of the track and simply welding it manually.
This does not work.
Makeineer
(Makeineer)
September 27, 2021, 2:56pm
#6
Consider adding a thin part which covers the middle of the track, then turning off CanCollide for a small layer of your train car, as in a layer.
SwissGermanGuy:
This does not work.
Ah, my bad, then.
Do you mean something like this, and then build something around the center which covers my whole part?
I’ll be sure to try it out, this looks like a smart idea
Even though this somewhat works, my train becomes really glitchy now…
https://i.imgur.com/AKLiGN8.mp4
Makeineer
(Makeineer)
September 27, 2021, 3:33pm
#11
Maybe try allowing for a bit more space on turns?
We’re dealing with the physics engine here, so unfortunately there’s no non-dynamic fix to my knowledge.
1 Like
Pure_Bacn
(Pure_Bacn)
September 27, 2021, 6:04pm
#12
It won’t steer because your train is one block with no hinges, so there is no way it can turn.
It moves with the sliders, the wheels don’t actually collide.
Pure_Bacn
(Pure_Bacn)
September 29, 2021, 7:14am
#14
Then I would assume its cause the train is too “straight” if you get what I mean.
Makeineer
(Makeineer)
September 29, 2021, 6:04pm
#15
Unfortunately for this scenario, that is necessary. We’re working with physics here, rather than a scripted action, which wouldn’t work well here, either.
The only solution that I’ve come up with has simply been to create more slider space on corners, even if that means creating special hitboxes.
Not sure if the OP has solved this issue, but you can try making the bogie rotating along with the track.
1 Like
I’ll be sure to try this out, thanks for the tip!
1 Like