I have obtained a method to make my mech’s upper body to look at the mouse as seen below for my future mech game:
--Obtain the offset from the hip of the mech
local rootCFrame = pointer.LowerBody.Hip.CFrame;
local rotationOffset = (rootCFrame - rootCFrame.p):inverse();
--Obtain CFrame where torso looks at the target position
local goalCFrame = rotationOffset*CFrame.new(centerJoint,newLookAtVector)
local x,y,z = goalCFrame:ToEulerAnglesXYZ()
hipMotor.C0 = CFrame.Angles(x,y,z)
Now I’m trying new methods to constrain the mechs pitch while making it be able to rotate 360° around the torso.
First I clamped the pitch which worked
x = math.clamp(x,-0.55,0.3)
hipMotor.C0 = CFrame.Angles(x,0,0)
The problem starts with the yaw where it just doesn’t rotate 360 degrees like I would expect.
hipMotor.C0 = CFrame.Angles(0,y,0)
Then it gets worse when combined as the torso starts rolling which is undesirable for my purposes though it looks cool.
hipMotor.C0 = CFrame.Angles(x,y,0)
I’m trying the method suggested at the end of this thread.
Please give me further insight on how to make it move like this Euler angle visualization website.
http://www.ctralie.com.s3-website-us-east-1.amazonaws.com/Teaching/COMPSCI290/Materials/EulerAnglesViz/