im trying to get my player’s jump and gravity speed the same so my player and jump and fall at the same speed and also limit his jump height. this is the code
public class PlayerJump : MonoBehaviour {
public float jumpSpeed = 20;
public float gravity = 9.8f;
CharacterController controller;
Vector3 currentMovement;
// Use this for initialization
void Start ()
{
controller = GetComponent<CharacterController>();
}
// Update is called once per frame
void Update ()
{
if (!controller.isGrounded)
currentMovement -= new Vector3 (0, gravity * Time.deltaTime, 0);
else
currentMovement.y = 0;
if (!controller.isGrounded && Input.GetButtonDown ("Jump"))
currentMovement.y = jumpSpeed;
controller.Move (currentMovement * Time.deltaTime);
}
}