AlignOrientation based steering not doing anything

I have made a helicopter that uses AlignOrientation to stay stable. I could not, however, manage to make it rorateable with an AngularVelocity constraint, so I instead opted to use loops to let the player steer it by directly changing the AlignOrientation’s CFrame. It did not work; no errors, nothing, just a script that does nothing

Here’s the code:

local seat = script.Parent
local align = seat.Parent.Color.Center.AlignOrientation
local newcframe = CFrame.Angles(0,1,0)

function movement()
	if seat.Steer == 0 then
		align.CFrame = CFrame.Angles(0,0,0)
		while seat.Steer == 1 do
			align.CFrame = align.CFrame - newcframe
			task.wait()
		end
		while seat.Steer == -1 do
			align.CFrame = align.CFrame + newcframe
			task.wait()
		end
	end
end

seat.Changed:Connect(movement)

Making it change the value instead of adding with a loop works, but that wouldn’t let the player fully steer the helicopter. I hope someone knows what I’m doing wrong here and how I can do it right.

2 Likes

I tried changing it to this:

local seat = script.Parent
local align = seat.Parent.Color.Center.AlignOrientation
local newcframe = Vector3.new(0,20,0)

function movement()
	if seat.Steer == 0 then
		--align.CFrame = CFrame.Angles(0,0,0)
	elseif seat.Steer == 1 then
		align.CFrame = align.CFrame + newcframe
	end
end

seat.Changed:Connect(movement)

But it still doesn’t do anything. It’s weird since it doesn’t give me errors either.

1 Like

I give up on this method. I’ll try using AngularVelocity instead which works for what I’m trying to do, but I can’t use it with AlignOrientation no matter how I configure it. I need to find a way to make the helicopter stable without preventing it from steering.

1 Like

I need to find a way to make the helicopter stable without preventing it from steering.

As it turns out, I managed to make that work with a BodyGyro. It’s funny, BodyGyros were supposed to be deprecated in favour of AlignOrientation, yet it managed to serve a purpose AlignOrientation failed with. Thank goodness Roblox doesn’t get rid of deprecated things anymore.

local seat = script.Parent
local velo = seat.Parent.Color.Center.AngularVelocity

function movement()
	if seat.Steer == 0 then
		velo.AngularVelocity = Vector3.new(0,0,0)
	elseif seat.Steer == 1 then
		velo.AngularVelocity = Vector3.new(0,-2,0)
	elseif seat.Steer == -1 then
		velo.AngularVelocity = Vector3.new(0,2,0)
	end
end

seat.Changed:Connect(movement)
1 Like

Nevermind. The BodyGyro isn’t doing what it should, the helicopter can’t stay aligned. I don’t know what to do anymore.

1 Like

You can’t make it rotateable using AngularVelocity probably because AlignOrientation is conflicting with it.

1 Like

Yes, I’m pretty sure that is the case. AlignOrientation must be preventing it from rotating, so I wanted to know how to keep it aligned while having one of the axis unlocked so it can only rotate (no tilt, etc). Unfortunately I haven’t been able to.

2 Likes

You need to make sure it’s only operating on the Y axis, and I’m pretty sure there’s a property for that.

1 Like

Sorry for the late answer but I tried everything I could to do what you said before your reply. Nothing worked, and it’s odd because what you said should be possible according to documentation and other articles I’ve read in the forum, but nothing worked for me.

1 Like

Try upping the AngularVelocity’s speed. Passing Vector3.new(0, 2, 0) means you’re rotating it by 2 degrees per second. You might just not be noticing it rotating. Also, is the attachment set properly? I always forget to add the attachment to constraints like that, and they require one to work.

1 Like

Everything’s in check. It just won’t work no matter what. Maybe it has to do with the model of the helicopter. I honestly don’t even know anymore, maybe it’s a sign I shouldn’t put a helicopter in my game.