I am trying to create a simple ball shooter game, the cylinder which is acting as a gun can be rotated about the local x and z axis to fire up/down and left/right. The problem comes when you combine several rotations, you end up looking at the world at a very odd angle. I tried locking the y rotation but this didn’t help.
Is there a way of panning up/down and left/right without ending up at an odd angle to the horizon?
I couldn’t tell from what was shown, but is the cannon itself centered in a way where it can rotate with the floor? I ask, because the area where the cannon’s center is will change how it rotates on the Y axis in relation to the ground.
I’m not sure I get what you mean. It begins parallel to the floor with the local co-ordinates aligned with the global co-ordinates, so yes, when you initially rotate about the z axis it remains parallel to the floor. Its when you combine a rotation about the z axis with a rotation about the x axis that I get the unwanted rotation about the y axis.
I’ve partially fixed it by adding additional controls to rotate about the y axis, this means that you can get it back upright, is there a way of doing this automatically?
I also tried using a “track to” actuator with an empty above the gun but this prevented the motion actuators working.
Could you maybe explain this in more detail or point me in the direction of a tutorial, I’ve tried with three parented empties, one for the z rotation, one for the x rotation and another above the cylinder with a TrackTo actuator applied to the cylinder to keep it pointing at the empty. Unfortunately the cylinder wouldn’t move at all with this setup.
Azimuth rotation should be around global axis, while elevation should remain local. So I suggest you deselect the “L” options of the actuators driven by right/left arrows.