Train can't steer

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
1 Like

I do not have any SpringConstraints, and my train runs on the track via a system which looks like this

2 Likes

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.

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.

Ah, my bad, then.

Do you mean something like this, and then build something around the center which covers my whole part?


Something like this.

I’ll be sure to try it out, this looks like a smart idea :slight_smile:

Even though this somewhat works, my train becomes really glitchy now…
https://i.imgur.com/AKLiGN8.mp4

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

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.

Then I would assume its cause the train is too “straight” if you get what I mean.

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