Need a little advice on limiting the rotation of a component on a moving actor.
I have a vehicle, with a turret on the right side. As the player moves around the world, it detects targets and turns the turret to face and shoot at the targets. Currently, I get the Look at the rotation of the target and the turret pivot, I rotate the gun and fire. I have used a clamp angle node to limit the Y (Pitch) angle so that the turret doesn’t aim too high/too low and this works well.
I want to limit the turret’s rotation to 180 degrees on the Z (Yaw) axis (so it cannot shoot through itself); however, as the vehicle moves, a clamp value won’t work here as the Z value is continuously changing with vehicle rotation.
What is the best approach to limiting the rotation of the turret to 180 degrees from its relative position?
if you want to use World Rotation for the turret (which you should not, this is a job for Relative Rotation, but it can be made to work), the Min & Max should also be derived from the world rotation of the parent vehicle.
this is a job for Relative Rotation
Here’s an example of angle locked relative rotation with transforms, derived from the Look at Rotation node: