As you can see the turrent moves however it goes a bit further than the metal square sometimes. I’m trying to get it so its moves around the metal square.
I think setting the PivotTo property to 5,0,0 lowers the distance between the turrent and metal square however I still haven’t found a suitable solution.
Well seeing some code would help us better help you but it looks like your just making the turrent look at the mouse position, I’m not sure your making it relative to the metal sqaure
What’s happening is you’re just rotating the turret around it’s centre.
What you could try is taking the mouse’s 2D position on the screen and then use that to control the speeds of a horizontal and vertical Torque on the turret, however you’re going to have to work out where the hinges go yourself.
If you look at the video you can see the entire turret moving around it’s pivot point. You need to set a model’s PrimaryPart so the script rotates around the location you want (or set the Pivot of the Model using the Pivot Editing tools in the Model Tab in Studio.
For this type of turret you want 2 points of rotation.
The base should be it’s own model and it should have the Cylinder as the PrimaryPart so it rotates around it.
The cannon should be a model and have its PrimaryPart as the pivot point for the gun.
Make the horizontal movement of the mouse move the base and the vertical movement tilt the gun and player seat.
It’s a bit more work, but it’ll make it work better.
If you want to make it all one piece then I’d suggest putting a Ball Part under the Cylinder and make that the PrimaryPart of the entire gun. That way your CFrame script will rotate and tilt around the Sphere and it won’t look as twisted as your setup.
I made an anti-aircraft gun in my Bomber place if you’d like to take a look.
It’s driven by the VehicleSeat controls so the control system won’t work for you, but you’ll see the movement I mentioned. I used HingeConstraint set to Servo for raising and lowering since that is limited, and one set to Motor for the rotation since it can keep going in circles.
Just have a look at my Roblox profile places, it’s the B-25 bomber. The anti-aircraft gun is close to the spawn.
Since the whole gun is a union, I made a model with only the diamondplate base in it and put the union in the model, after I set the PrimaryPart of the model to the union but it still produces the same result.
I thought that if I were to set the primarypart of the base to the union then the union would rotate around the metal square(base)
While I was messing around with the turrent I found out that when I was creating the union, the first part I selected was where the turrent would pivot off of. So I selected it to a part in the middle of the turrent and it now works.