How to make 3 Turrets On a vehicle Rotate to a single crosshair

I have tried a lot of methods from different sources… but still couldn’t find a way to make the 3 turrets rotate to a single crosshair…

  • AddLocalRotation connected to mouse InputAxis method gives a smooth turn until I turn the vehicle the turret turns with it
  • SetWorldRotation method has problems when vehicle gets on a ramp… well you know why…

The turrets (gun with base as a parent) are childed to a socket of the main vehicle.
please help to make this work…
camera is connected to a spring arm childed to the main vehicle

try playing with FindLookAtRotation.

It is still having problems.

What part am I doing wrong?

maybe you should make the guns out of 3 parts parented to each other. the base of the gun is stationary, and keeps track of the default rotation relative to the body of the vehicle. the turret is attached to that base, and rotates relatively around Yaw, and the barrel is attached to the turret and rotates relatively around pitch.

using set relative rotation works as long as your camera has the same orientation as the base of the gun. to make it work for arbitrary camera rotations, you will probably have to use combine rotators to add the inverse of the cameras rotation to the vehicles rotation, to cancel out the differences between relative and world coordinates

Instead of Making 3 parts I took the default rotation directly from the vehicle, Inverse vehicle rotation with camera rotation as you said added them including some error fixes and connected it to SetRelativeRotation and it worked… now all I need to do is to add some clamp to avoid overlapping the gun barrel with the base… and continue doing the same with other guns. Thanks for your Help!!