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

Plane Z-axis rotation overridden by plane changing direction?

Asked by 6 years ago
Edited 6 years ago

In a project I am working on, I have plane that will change its lookvector via a BodyGyro controlled by the user's mouse. I have been able to make the plane rotate on it's Z-Axis and it will maintain its current roll until the mouse is moved again, creating an entirely new CFrame for the BodyGyro. I would like the direction of the plane to change without automatically resetting the plane's roll. I am not sure how to go about this. Any advice would be greatly appreciated!

Plane Roll

while KeyDown do
            seatpart.Value.Parent.Front.BodyGyro.CFrame = seatpart.Value.Parent.Front.BodyGyro.CFrame * CFrame.Angles(0,0,-math.rad(2))
            wait()
        end

Plane Velocity

function mousemove()
    local gyro = seatpart.Value.Parent.Front:WaitForChild("BodyGyro")
    Player.Backpack.Folder.Direction.Value = mouse.UnitRay.Direction
    seatpart.Value.Parent.Front.BodyVelocity.Velocity =                 seatpart.Value.Parent.Front.CFrame.LookVector * 75
    gyro.CFrame = CFrame.new(seatpart.Value.Parent.Front.CFrame.Position, mouse.Hit.p)
    wait()
end

mouse.Move:Connect(mousemove)

Here is a gif illustrating my issue. Notice how as soon as I move the mouse, any rotation along the Z-Axis is reset.

0
Do use local variables thanks. and CFrame.p is deprecated, use CFrame.Position. User#19524 175 — 6y
0
I went ahead and added the local variables. Are you referring to mouse.Hit.p? pieguy100000 28 — 6y

Answer this question