Here is my cube:
It moves diagonally, up, left, right, and down. However, I would really like to add in running to this script. I want to grab the current direction in which the object is traveling and multiply the speed by two.
using UnityEngine;
using System.Collections;
public class CharacterController : MonoBehaviour
{
public float moveSpeed = 1f;
void FixedUpdate()
{
if (Input.GetKey(KeyCode.W))
{
transform.Translate(Vector3.up * moveSpeed * Time.deltaTime);
}
if (Input.GetKey(KeyCode.A))
{
transform.Translate(Vector3.left * moveSpeed * Time.deltaTime);
}
if (Input.GetKey(KeyCode.S))
{
transform.Translate(Vector3.down * moveSpeed * Time.deltaTime);
}
if (Input.GetKey(KeyCode.D))
{
transform.Translate(Vector3.right * moveSpeed * Time.deltaTime);
}
}
}
Thanks! (P.S. This is my first post!)