Well,
I’m following a tutorial on YouTube for a first-game in Unity.
In this case driving around in a car.
I’m trying to rotate my car left and right, but with no movement.
So when I’m pressing “W” It’s going forward,
But the problem is:
When I press “D”, it goes right indeed, but it goes forward as well!
When I press “A”, it goes left indeed, but it goes backwards as well…
When I press “W” + “A” it goes super-slow forward and turns left,
When I press “W” + “D”, it goes super-fast forward and turns right.
What could be wrong?
(This is C#)
using UnityEngine;
using System.Collections;
public class CarAll : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if( Input.GetKey ( KeyCode.W) ) {
transform.position += transform.forward * 5.0f * Time.deltaTime;
}
if( Input.GetKey ( KeyCode.S) ) {
transform.position -= transform.forward * 2.0f * Time.deltaTime;
}
if( Input.GetKey ( KeyCode.A) ) {
transform.Rotate( 0.0f, -80.0f * Time.deltaTime, 0.0f);
}
if( Input.GetKey ( KeyCode.D) ) {
transform.Rotate( 0.0f, 80.0f * Time.deltaTime, 0.0f);
}
}
}