hiya im just asking if this script is right because it all works till i ask it to allow me to tilt the camera on the X axis
using UnityEngine;
using System.Collections;
public class FirstPersonController : MonoBehaviour {
public float movementSpeed = 5.0f;
public float mouseSensitivity = 5.0f;
public float updownRange = 40.0f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
// Rotation
float rotLeftRight = Input.GetAxis ("Mouse X") * mouseSensitivity;
transform.Rotate (0, rotLeftRight, 0);
float rotUpDown = Input.GetAxis ("Mouse Y") * mouseSensitivity;
Camera.main.transform.Rotate( rotUpDown, 0, 0 );
// Movement
float forwardSpeed = Input.GetAxis ("Vertical") * movementSpeed;
float sideSpeed = Input.GetAxis ("Horizontal") * movementSpeed;
Vector3 speed = new Vector3 (-sideSpeed, 0, -forwardSpeed );
speed = transform.rotation * speed;
CharacterController cc = GetComponent<CharacterController> ();
cc.SimpleMove ( speed );
}
what happens is i get stuck and all i can do is look around in a 360 rotation
using UnityEngine;
using System.Collections;
public class FirstPersonController : MonoBehaviour {
public float movementSpeed = 5.0f;
public float mouseSensitivity = 5.0f;
public float updownRange = 40.0f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
// Rotation
float rotLeftRight = Input.GetAxis ("Mouse X") * mouseSensitivity;
transform.Rotate (0, rotLeftRight, 0);
float rotUpDown = Input.GetAxis ("Mouse Y") * mouseSensitivity;
Camera.main.transform.Rotate( rotUpDown, 0, 0 );
// Movement
float forwardSpeed = Input.GetAxis ("Vertical") * movementSpeed;
float sideSpeed = Input.GetAxis ("Horizontal") * movementSpeed;
Vector3 speed = new Vector3 (-sideSpeed, 0, -forwardSpeed );
speed = transform.rotation * speed;
CharacterController cc = GetComponent<CharacterController> ();
cc.SimpleMove ( speed );
}
what happens is i get stuck and all i can do is look around in a 360 rotation