Mouse Controlled Turret with Base Turning on the X- Axis and the Elevator on the Y - Axis but dragged with the Base

Here’s the turret itself. (Supposed to be a radar rangefinder), point is, two different hinges,
image


Here’s how it’s built:
image


Here’s the gameplay.
https://imgur.com/FyE7WDS


All of the hinges use Servo Actuator Type for moving, I can send pictures of the hinge orientation if necessary.

Here is the function:

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?

Yes they can move each other and the function will calculate the correct angle based on relative positon.

This angle calculation is based on world position as it doesnt have to Object Space in it.

Right, but what I’m looking for is how to calculate the Yaw Angle for the white part in the image, to rotate up and down.

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.

Yeah the hinges should be in different axises.

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.

I remember seeing this model on the dev forum but here is the link credits to the owner:

https://create.roblox.com/marketplace/asset/7131701158/TurretModelTest

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.

image

But then when it’s close then it’s facing correctly?

image

Another example of how it looks:

image

Any ideas regarding what should I do?

Try using my function

I used your function for yaw, but not pitch, wouldn’t it have to be slightly different?

Does the AngularResponsiveness matter in this case?
image

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.

Still kinda stuck on this question, looking for ideas in regards to how I could solve this problem

Is anything welded to the base?

Nope, I don’t think so, as far as I’m looking right now I don’t think anything is welded to the base. Only the leg.
image

Fixed, just played around with the hinge, it works but not very accurate.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.