I’m trying to make a tracking system using VR, but I’m having issues with eulerAngles.
The goal of the system is to rotate the character when the headset rotates, but this can’t be done because of the maximum radians for that axis which would be 1/2 pi but I require a larger number for my method to work.
Here is some code specific to the rotation.
HumanoidRootPart.CFrame = (HumanoidRootPart.Position * CFrame.Angles(0, y, 0))
where y
would be the radians that I got from the method CFrame:toEulerAnglesXYZ()
and the CFrame would be my HTC Vive headset.
Is there another way to do this or am I missing something?
Hopefully this solves the issue:
local player = game:GetService("Players").LocalPlayer;
if (not player.Character) then player.CharacterAdded:Wait(); end
local humanoid = player.Character:WaitForChild("Humanoid");
humanoid.AutoRotate = true;
2 Likes
I found what the issue was with the help of @EssenceExplorer. While researching CFrames and looking at some other questions I didn’t know that Euler angles are not all the same. For example YXZ is going to apply differently than XYZ. They have different ending positions. Because the VR code does YXZ and not XYZ it applied a different rotational value to the CFrame than normal causing both the Y and Z axis to change when only moving the headset on the Y axis in real life. Here is the post that helped me realize this : What is the difference between the Orientation
and Rotation
propertry - #7 by Elttob
Thanks for all the help
2 Likes