Trying to write my own FPS movement script. Character can only move backwards?

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);
		}
	}
}

Also you could define the “GetComponent();” in the start function so its not called every frame. I would so something like this…

using UnityEngine;
using System.Collections;

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;
    private CharacterController controller;

    // Use this for initialization
    void Start()
    {
        controller = GetComponent<CharacterController>();
    }

    // Update is called once per frame
    void Update()
    {
        if (controller.isGrounded && controllable)
        {
            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);
    }
}

Wow, the answer is not hidden in code.

I forgot that the hands I gave to my character have colliders to them, and I removed the colliders. It’s all good now.