Hello everybody, I seem to be having trouble with my characters movement rotating on the X axis. Basically the problem is that it works perfectly on another computer, however when I use the script on this project it doesn't seem to work and I cannot, for the life of me work out what I am missing. The Yaxis movement works as intended, the character movement/jumping works as intended however the camera nor the player gameobject itself rotate on the Xaxis. This is my Character controller script: Code (CSharp): using UnityEngine; using System.Collections; public class CharacterController2 : MonoBehaviour { public float speed = 6.0F; public float jumpSpeed = 8.0F; public float gravity = 20.0F; private Vector3 moveDirection = Vector3.zero; void Update() { CharacterController controller = GetComponent<CharacterController>(); if (controller.isGrounded) { moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")); moveDirection = transform.TransformDirection(moveDirection); moveDirection *= speed; if (Input.GetButton("Jump")) moveDirection.y = jumpSpeed; } moveDirection.y -= gravity * Time.deltaTime; controller.Move(moveDirection * Time.deltaTime); } } and this is my Cameracontroller Script: Code (CSharp): using UnityEngine; using System.Collections; public class CameraController : MonoBehaviour { public GameObject camera; float cameraRotX = 0f; public float cameraPitchMax = 70f; // Update is called once per frame void Update () { cameraRotX -= Input.GetAxis ("Mouse Y") * 5f; cameraRotX = Mathf.Clamp (cameraRotX, -cameraPitchMax, cameraPitchMax); Quaternion rot = Quaternion.Euler (cameraRotX, 0, 0); transform.localRotation = rot; } } Also if this is any use here is my game object hierarchy in the editor: And here's the Camera Component: Any help would be much appreciated, thanks in advance. edit: removed image links and manually uploaded
What but doesn't work on the new PC? Does it move but not the correct way or does it just not move at all? Any console messages?
Everything works appart from the Xaxis horizontal rotation (Mouse movement) on the character, ie. he cant look left or right, but can look up and down when using the mouse.
I don't have my PC handy & it's late here so this may be wrong, but if the character is looking left/right shouldn't the rotation be around the Y axis?
Yeah this is the only error I seem to get: Assets/Scripts#/CameraController.cs(6,27): warning CS0108: `CameraController.camera' hides inherited member `UnityEngine.Component.camera'. Use the new keyword if hiding was intended
In your script you are setting the y rotation to 0 & the x rotation to the value you want. I think it should be the other way around