Bugs on move in air(falling);
I want the player to be able to move while in air(falling) a bit.
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;
}
}
This just work if you move befor and not in air.
And at this my Player bugs in air and fall instand and fast down (not jump as high as in the first script).
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;
}
}else {
moveDirection = Vector3(Input.GetAxis("Horizontal"), moveDirection.y,
Input.GetAxis("Vertical"));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection.x *= speed / 2;
moveDirection.z *= speed / 2;
}
Thx for all they help, Hollo1001. :D
Comment