Hello!
Im triying to make a game where you fly on a plane.
Right now, this is a part of my code:
local Hearbeat = RunS.Heartbeat:Connect(function(delta)
local MoveDir = Humanoid.MoveDirection
AlignO.CFrame = CFrame.Angles(math.rad(PrimaryPart.Orientation.X)-MoveDir.Z, math.rad(PrimaryPart.Orientation.Y)-MoveDir.X,0)
print(AlignO.CFrame.Rotation:ToOrientation())
Camera.CFrame = CFrame.lookAt(HRP.Position+HRP.CFrame.LookVector*(-30)+HRP.CFrame.UpVector*10, HRP.Position)
LinearV.VectorVelocity = PrimaryPart.CFrame.LookVector*Speed
end)
The plane should rotate up when you try to walk to front, down when you try to walk back, rigth when rigth, and left when left. It should also look to the place it is triying to go. The problem. Is that every Angle CFrame constructor functions works internally on a way that rotates the z axis and thats why the print()
function on line 4 print this:
[...] -->I just pasted the last prints
0.00023475373745895922 1.622352957725525 -0.0045492565259337425 - Client - MainPlayerModule:31
22:48:16.281 0.00020964026043657213 1.6223703622817993 -0.004061209969222546 - Client - MainPlayerModule:31
22:48:16.290 0.00019884337962139398 1.6223704814910889 -0.0038520488888025284 - Client - MainPlayerModule:31
22:48:16.310 0.0001844475482357666 1.6223704814910889 -0.0035731676034629345 - Client - MainPlayerModule:31
22:48:16.328 0.00016740891442168504 1.6223880052566528 -0.003241993021219969 - Client - MainPlayerModule:31
22:48:16.393 0.00012604956282302737 1.6224056482315063 -0.00244020763784647 - Client
As you can see, the Z component of the CFrame has rotation.
I tried it with this functions:
CFrame.lookAt()
CFrame.Angles()
CFrame.fromEulerAnglesXYZ()
Do anyone has any idea?