Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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

Log in to vote
0
Answered by 4 years ago

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)
0
May I ask? What does fromEulerAnglesXYZ() do? PhantomBrix 40 — 4y
0
Changes orientation/rotation I guess. Edbotikx 99 — 4y
0
thanks PhantomBrix 40 — 4y
Ad

Answer this question