Rotating object's xyz-axis but not its mesh

Hello! I´m making an air balloon simulator containg an air balloon and a first person camera in it.

I want my air balloons mesh to not rotate, but I want the balloon to move towards where the first person camera is pointing and it seem like the xyz-axis depends on the objects rotating. Is there any way to get around this?

My parts: Balloon, camera, part1, part2, part3

So how and where do I put my movement and mouse look scripts, and how do I solve this?

Thankful for an answer!

If you are using FPSController, edit your MouseLook script on FPSController and on update function, add “Camera.current.” prefix before all transform operations. Your Update function must be look like this:

void Update ()
	{
		if (axes == RotationAxes.MouseXAndY)
		{
			float rotationX = Camera.current.transform.localEulerAngles.y + Input.GetAxis("Mouse X") * sensitivityX;
			
			rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
			rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
			
			Camera.current.transform.localEulerAngles = new Vector3(-rotationY, rotationX, 0);
		}
		else if (axes == RotationAxes.MouseX)
		{
			Camera.current.transform.Rotate(0, Input.GetAxis("Mouse X") * sensitivityX, 0);
		}
		else
		{
			rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
			rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
			
			Camera.current.transform.localEulerAngles = new Vector3(-rotationY, transform.localEulerAngles.y, 0);
		}
	}

Goodluck :wink:

If I understood correctly what you want, my suggestion is to child the camera to the balloon and attach the MouseLook script to the camera, setting its Axes field to “Mouse X and Y” - this way you can look up/down/right/left with a single MouseLook. To move in the direction the camera is looking at, move the balloon in the camera’s forward vector. If you want to control the vertical movement with the camera too, multiply the Y component by some factor between 0 and 1 - this way you can control how much the vertical camera swing affects the vertical movement.

If you need to detect collisions, add a CharacterController to the balloon and use Move; if not, simply use Translate (with Space.World specified). That’s a basic movement script (attach it to the balloon):


var speed: float = 5.0;
// how much the up/down camera movement influences the balloon vertical movement:
var vSensitivity: float = 0.2;

function Update(){
  // get the camera's forward direction:
  var dir = Camera.main.transform.forward;
  // apply part of the vertical cam direction to the vertical movement:
  dir.y *= vSensitivity;
  // control forth/back movement with the Vertical axis:
  var move = dir.normalized * Input.GetAxis("Vertical") * speed * Time.deltaTime;
  // Translate version:
  transform.Translate(move, Space.World);
  // CharacterController version:
  GetComponent(CharacterController).Move(move);
}

NOTE: Remember to keep only one of the movement instructions (Translate or Move), deleting or commenting out the unused one.