Using transform.LookAt() but allow modification of one axis.
Game is viewed from behind the player ship, think Star Fox. Player's "forward" is on the x axis, "up" is on the y axis, and "depth' is on the z axis. Left analogue stick controls player movement, right analogue stick controls a crosshair that can travel around the screen.
I use the following C# script to make the player ship "look at" the cross hair. (if the cross hair is above the player ship, it rotates up, etc)
private void RotationRoutine3D()
{
var point = new Vector3(_crossHair.position.x, _crossHair.position.y, _crossHair.position.z);
transform.LookAt(point);
transform.Rotate(-90, 0, 270); // adjustments for weird blender import;
}
This works as expected, but I also wish to implement a 'barrel roll' action, in which the player ship would rotate along it's x axis. All attempts have lead to a Gimbal Lock like situation; if I rotate on the x axis, it appears that the ship rotates along the y axis, if I rotate on the y or z axis, the ship rotates along the z axis.
Any help would be greatly appreciated.
EDIT: Adjustments to Code Snippet.