- Home /
Character refuses to turn
My character wont turn. I think i have a bug in my code I cant see. using UnityEngine; using System.Collections;
public class Movement : MonoBehaviour
{
public float turnspeed = 135f;
public float speed = 2f;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
float rot = Input.GetAxis ("Mouse X");
float horiz = Input.GetAxis ("Horizontal");
Debug.Log (rot);
float vert = Input.GetAxis ("Vertical");
gameObject.transform.Rotate (new Vector3 (0, rot * turnspeed, 0));
gameObject.transform.Translate (new Vector3 (horiz, 0, vert) * speed * Time.deltaTime);
if (-gameObject.transform.up != Physics.gravity) {
transform.up = -Physics.gravity;
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
I keep getting an error when try to change the tag of a gameObject 1 Answer
Pressing E three times in order for it to work. 1 Answer
ground detection fails 0 Answers