So I have a tank model in a point-and-click game. The way I’m doing it is if you right click a location, the turret on the tank rotates to that location but not the base of the tank itself.
obj.transform.rotation = Quaternion.Slerp(obj.transform.rotation, Quaternion.LookRotation(myhit2.point - obj.transform.position), Time.fixedDeltaTime * 3);
However if you click at the top of a building, the raycast point is not at the same plane as the turret and it will point up at the top of the building. This makes the turret in the model rotate funny and clip the model as it’s a left/right articulating turret only.
My question is, how can I get the turret to rotate in the direction of the hit point, but not look up at it (i’ll be shooting at other tanks and wont need to aim up).