Well, at least I am learning to write my own first person movement script. For some reason I can only move backwards. Forwards does nothing, and I can strafe very very slowly.
I am writing this for my multiplayer sorta test that uses PUN.
public class PlayerController : MonoBehaviour {
public bool controllable = false;
public float speed = 7.0f;
public float jumpSpeed = 6.0f;
public float gravity = 20.0f;
private Vector3 moveDirection = Vector3.zero;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if(controllable) {
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);
}
}
}