Hello,


I have scripted a simple turret that can shoot at arbitrary targets.
The turret itself can only be rotated about the Z axis (pan). Its barrel can only be rotatet about the Y axis (tilt).

The script works fine as long as the turret is located on a plane floor.
However if it is standing on a wall or a ceiling it doesn't work anymore.

I know how to rotate the turret about its local axes; what i don't know is:
How do I calculate the direction vector accordingly, so that the turret can be rotated to its target (while being arbitrary oriented)?


Any help is appreciated.