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):
01 | local seat = script.Parent.VehicleSeat |
02 | seat.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 |
Are there any other ways that I could just rotate the boat to face it's RightVector and LeftVector (-RightVector)?
Lol, I'm working on the same exact thing you are at the moment. Here's what I came up with.
01 | local Control = script.Parent.Parent.Parent.Hull.Control |
02 |
03 | script.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 |
15 | end ) |