Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Boat steering: BodyAngularVelocity isn't working? (no errors in output)

Hi, My game needs a boat for the player to buy and then drive, I finished going forward and stopping but I'm using BodyAngularVelocity for the steering and the code is as following (using VehicleSeats):

local seat = script.Parent.VehicleSeat
seat.Changed:Connect(function(p)
	-- forward/backward code goes here

	--steering
	if p == "Steer" then
		if seat.Steer == 1 then
			-- go right
			script.Parent.PrimaryPart.BodyAngularVelocity.AngularVelocity = script.Parent.PrimaryPart.CFrame.RightVector

		elseif seat.Steer == -1 then

			--go left
			script.Parent.PrimaryPart.BodyAngularVelocity.AngularVelocity = 
                       -script.Parent.PrimaryPart.CFrame.RightVector

		else

			-- no steer
			script.Parent.PrimaryPart.BodyAngularVelocity.AngularVelocity = Vector3.new(0,0,0)
		end
	end
end)

Are there any other ways that I could just rotate the boat to face it's RightVector and LeftVector (-RightVector)?

1 answer

✓ Accepted answer

Lol, I'm working on the same exact thing you are at the moment. Here's what I came up with.

local Control = script.Parent.Parent.Parent.Hull.Control

script.Parent:GetPropertyChangedSignal("Steer"):Connect(function()
	if script.Parent.Steer == 1 then
		while script.Parent.Steer == 1 do
			Control.BodyGyro.cframe = Control.BodyGyro.cframe * CFrame.fromEulerAnglesXYZ(0,-0.5,0)
			wait(1)
		end
	elseif script.Parent.Steer == -1 then
		while script.Parent.Steer == -1 do
			Control.BodyGyro.cframe = Control.BodyGyro.cframe * CFrame.fromEulerAnglesXYZ(0,0.5,0)
			wait(1)
		end
	end
end)

3 comments

0

May I ask? What does fromEulerAnglesXYZ() do?

0

Changes orientation/rotation I guess.

0

thanks

This discussion is preserved as it was. New answers, comments, and votes are closed.