(Sorry if I’m posting this is a wrong category, I couldn’t find the correct one.)
So basically, I’m making a train movement system using LinearVelocity, but my train keeps going side to side (rotating on the X axis).
Is there a way to completely disable rotation by the X axis using AlignOrientation or if not, are there any other solutions to this?
Any help will be appreciated, thank you.
just rotate the X axis to the same X axis
I’ve made a script that if the train rotates by the X axis, sets it to 0, but the train still manages to derail.
1 Like
Could you send me the code by any chance?
It’s not a complicated script…
script.Parent:GetPropertyChangedSignal("Orientation"):Connect(function()
script.Parent.Orientation = Vector3.new(0, script.Parent.Orientation.Y, script.Parent.Orientation.Z)
end)
1 Like
nonamehd24
(nonamehd24)
August 22, 2022, 6:57pm
#6
GetPropertyChangedSignal doesn’t fire on stuff changed by the engine. You would need to put it in a Heartbeat.
local Part = script.Parent
game:GetService("RunService").Heartbeat:Connect(function()
Part.Orientation = Vector3.new(0, Part.Orientation.Y, Part.Orientation.Z)
end)
1 Like
The train doesn’t move now. It looks like it’s trying to get somewhere but is being put back to it’s original position.
nonamehd24
(nonamehd24)
August 22, 2022, 7:05pm
#8
Then you could try putting a -5 value in the LinearVelocity.
1 Like
nonamehd24
(nonamehd24)
August 22, 2022, 7:11pm
#10
I mean a -5 Value in the Y position.
1 Like
Well, it still does the same thing. I’ve tried -5 and -15.
nonamehd24
(nonamehd24)
August 22, 2022, 7:23pm
#12
Actually you can use AlignOrientation in One attachment mode and specify an Orientation using primary axis.
1 Like
Scottifly
(Scottifly)
August 22, 2022, 7:23pm
#13
Is the train going to only go straight? If so just use a PrismaticConstraint.
If the train is supposed to turn corners then you are going to have issues with AlignOrientation not keeping it on the rails.
Or try Searching the forums.
I’ve helped a couple people on other posts using Constaints for trains.
1 Like
Will it make the train turn only by Y and Z? How do I do that?
nonamehd24
(nonamehd24)
August 22, 2022, 7:25pm
#15
AlignOrientation will align by Axis meaning that you have to find out a right axis.
1 Like
I want the train to turn on turns.
I’ve tried searching the forums, but I didn’t find anything helpful.
Scottifly
(Scottifly)
August 22, 2022, 7:27pm
#17
If you want AlignOrientation to only work on 2 axes then only put large Force values in those.
For example if you need no force on the Y axis then make the Force (100000,0,100000)
*** EDIT ***
Sorry, I was thinking of a BodyGyro.
There are a few different ways that AlignOrientation works, depending on if you have Mode (One or Two Attachments) and the 3 AlignOrientation properties checked off.
If you check the PrimaryAxisOnly property then another one pops up called AlignType.
It’s a whole lot of information to figure out. Here’s a Roblox example place that shows each way of setting the constraints up. They seem to have taken it down, but I managed to download it from the site.
New Body Movers, Physics, Constraints Example.rbxl (35.0 KB)
Play it in Test mode from Studio and you can see the way the properties are set up in each example.
2 Likes
Well, I’m used to working with BodyGyro and seeing this new AlignOrientation is very confusing for me…
Scottifly
(Scottifly)
August 22, 2022, 7:30pm
#19
1 Like
Scottifly
(Scottifly)
August 22, 2022, 7:33pm
#20
But BodyGyro worked the same way, you just put a 0 value in for the value that you want it to be able to spin on.
1 Like