Here is the diagram of how it works, the only difference is the X and Z axis is swapped because of how Hinge Constraints works and which axis they use:
The first function seems to be working pretty well, except that it’s a little 90 degrees to the right and by subtracting 90 degrees to it seems to fix the problem, maybe there’s another solution to this tho. Except for that your function essentially does what I’m able to replicate already, what I’m looking is how to make the bottom part (which is shown in the game), to turn on the Y Axis (Up and Down) on the Pitch angle instead of the yaw.
– But I also want it to turn together with the Yaw Angle by having the other hinge move it, can a hinge move another hinge or would they break?
Still looking for some help if anyone got any other ideas regarding how I could find a solution to this problem. I want to figure out how I can control the pitch turn of the turret and make the other hinge turn as well together on the yaw.
Are you looking for a effect like the videos below which also pitch and yaw?
If so I think you have a rigging problem like making the pole on the base rotate (RadarLeg joined with the RadarBase) instead of the radar elevator perhaps.
Wow that’s exactly what I’m looking for, the way you’re making the object rotate is exactly what I need.
I want my base to rotate individually and then the other part to rotate together with it (like the gun in your video), to move on the pitch to face the object. The object in my context is my mouse.
So what should I do to make that happen? Something I can do usinghinges?
Also, what do you mean by rigging problem? Are you telling me I should make the pole rotate instead of the head of the turret? The base itself and the leg don’t turn.
One should be pointing horizontal to rotate along the local X axis, this makes it rotate up and down to shoot planes “Pitch”. Labeled as 1 on the figure.
One should be pointing vertical on the Y axis which is the base located on the seat to make it “Yaw”. I labeled as 2 on the figure.
Wow this seems to work! Exactly what I’m looking for! Thank you!
The hinges that I made seem to be accurate and move correctly, but there’s a slight problem, my calculations for finding the Pitch seem to be inaccurate.
This is what I am trying to do to find the pitch:
local myX = (rayMousePosition.X - RadarLeg.Attachment0UpDown.WorldPosition.X)
local myY = (rayMousePosition.Y - RadarLeg.Attachment0UpDown.WorldPosition.Y)
local thetaY = math.atan2(myX, myY)
RadarLeg.HingeConstraintUpDown.TargetAngle = math.deg(thetaY)
The center part seems to be looking down for some reason, I tried edding some degrees to it at the final s for the current angle but it doesn’t seem to work.
But then when it’s close then it’s facing correctly?
I tried using a Roof Pitch Formula to try and calculate the angle at which to face but it doesn’t seem to work, tried doing an inverse calculations of that but it also doesn’t seem to work.