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 5 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):

01local seat = script.Parent.VehicleSeat
02seat.Changed:Connect(function(p)
03    -- forward/backward code goes here
04 
05    --steering
06    if p == "Steer" then
07        if seat.Steer == 1 then
08            -- go right
09            script.Parent.PrimaryPart.BodyAngularVelocity.AngularVelocity = script.Parent.PrimaryPart.CFrame.RightVector
10 
11        elseif seat.Steer == -1 then
12 
13            --go left
14            script.Parent.PrimaryPart.BodyAngularVelocity.AngularVelocity =
15                       -script.Parent.PrimaryPart.CFrame.RightVector
View all 23 lines...

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 5 years ago

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

01local Control = script.Parent.Parent.Parent.Hull.Control
02 
03script.Parent:GetPropertyChangedSignal("Steer"):Connect(function()
04    if script.Parent.Steer == 1 then
05        while script.Parent.Steer == 1 do
06            Control.BodyGyro.cframe = Control.BodyGyro.cframe * CFrame.fromEulerAnglesXYZ(0,-0.5,0)
07            wait(1)
08        end
09    elseif script.Parent.Steer == -1 then
10        while script.Parent.Steer == -1 do
11            Control.BodyGyro.cframe = Control.BodyGyro.cframe * CFrame.fromEulerAnglesXYZ(0,0.5,0)
12            wait(1)
13        end
14    end
15end)
0
May I ask? What does fromEulerAnglesXYZ() do? PhantomBrix 40 — 5y
0
Changes orientation/rotation I guess. Edbotikx 99 — 5y
0
thanks PhantomBrix 40 — 5y
Ad

Answer this question