Hey! I made my own movement and MouseLook Script, and I cant seem to move and jump at the same time.
Here the code:
using UnityEngine;
using System.Collections;
public class PlayerMovement : MonoBehaviour {
private float speed = 6f;
private float jumpForce = 16f;
private float gravity = 30f;
private Vector3 moveDir = Vector3.zero;
void Start () {
}
public void movementSpeed() {
if (Input.GetKey (KeyCode.LeftShift)) {
speed = 10f;
} else
speed = 6f;
}
void Update () {
CharacterController controller = gameObject.GetComponent<CharacterController> ();
movementSpeed ();
if (controller.isGrounded) {
moveDir = new Vector3 (Input.GetAxis ("Horizontal"), 0, Input.GetAxis ("Vertical"));
moveDir = transform.TransformDirection (moveDir);
moveDir *= speed;
if (Input.GetButtonDown ("Jump")) {
moveDir.y = jumpForce;
}
}
moveDir.y -= gravity * Time.deltaTime;
controller.Move (moveDir * Time.deltaTime);
}
}