Rotating object with mouse gets reversed on reversed side.

I have no idea how to search unity on this subject.

The problem is, when I rotate an object up object goes up, and left is left vs versa, but when I am on the opposite side of the game object everything is reversed. Now I move up, the game object goes down. Is there anyway to fix that?

I currently use this code;

using UnityEngine;
using System.Collections;
public class MouseRotate : MonoBehaviour {

	public int speed = 1;
	public int friction = 1;
	public int lerpSpeed = 5;
	private float xDeg;
	private float yDeg;
	private Quaternion fromRotation;
	private Quaternion toRotation;

	// Use this for initialization
	void Start () {
	// Update is called once per frame
	void Update () {
		if(Input.GetMouseButton(0)) {
			xDeg -= Input.GetAxis("Mouse X") * speed * friction;
			yDeg += Input.GetAxis("Mouse Y") * speed * friction;
			fromRotation = transform.rotation;
			toRotation = Quaternion.Euler(yDeg,xDeg,0);
			transform.rotation = Quaternion.Lerp(fromRotation,toRotation,Time.deltaTime  * lerpSpeed);

using UnityEngine;
using System.Collections;

I found these codes to do the trick, up is always up and left always left.

public class MouseRotate : MonoBehaviour {

public float RotationSpeed = 40;

// Update is called once per frame
void Update () {
		transform.Rotate((Input.GetAxis("Mouse Y") * RotationSpeed * Time.deltaTime), (Input.GetAxis("Mouse X") * -RotationSpeed * Time.deltaTime), 0, Space.World);

It works 100%, I was wondering of how can you make this smoother? In where it slows down then stops, I’m still new to quaternion lerp, I believe this is what makes it slows down and slowly speeds up the object. Not sure how to add quaternium to the formula.

Are you spinning completely around the X axis? Once something’s upside-down everything gets reversed. I usually limit X rotation so things can’t get past 90 or -90.

If you need full spin-around capabilities you’ll probably get the right results if you check X rotation and reverse your X input if the X rotation is >90 or <-90.