Hi all,
I’ve made my own script to rotate the camera with the mouse. It works fine right now; moving the mouse to the left, the right, up or downwards results in the camera looking that way. However, once the mouse reaches the edge of the screen, there’s no possibility to rotate any further. Can anyone help me on this?
The script:
using UnityEngine;
using System.Collections;
public class Move_Camera : MonoBehaviour {
public Vector3 oldmousepos;
void Start () {
oldmousepos = Input.mousePosition;
}
void Update () {
if (oldmousepos != Input.mousePosition) {
transform.Rotate (new Vector3(Input.mousePosition.y*-0.2f - oldmousepos.y*-0.2f, Input.mousePosition.x*0.2f - oldmousepos.x*0.2f, 0.0f));
oldmousepos = Input.mousePosition;
transform.parent.transform.Rotate(0,-this.transform.localEulerAngles.y,0);
transform.Rotate(0,-this.transform.localEulerAngles.y,-transform.eulerAngles.z);
}
}
}
The parent, in this case, is the player, while the camera is a child of the player.
Thanks!