Trying to make a top down game. left and right rotate the object and up and down move it forward and backward. I’m getting ver unexpected behavior with the code below
using UnityEngine;
using System.Collections;
public class TopDown_Movement : MonoBehaviour {
public float moveSpeed = 15f;
public float rotSpeed = 15f;
void Update () {
float x = Input.GetAxis("Horizontal") * Time.deltaTime * rotSpeed;
float y = Input.GetAxis("Vertical") * Time.deltaTime * moveSpeed;
transform.Rotate(0, x, 0);
transform.Translate(transform.forward * y);
}
}
If the object is facing north: it goes north.
If the object is facing east: it goes south
If the object is facing south: it goes north
If the object is facing northeast: it goes east.
Essentially, the visible rotation is exactly double the angle that corresponds to transform.forward. Any idea why this might be?
P.S. What is delta time in units of? Seconds?