Код
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MovePlayerTwo : MonoBehaviour {
public float speed = 1.0f;
float gravity = 20f;
public float jumpForce = 10f;
Vector3 direction;
CharacterController controller;
void Start()
{
controller = GetComponent<CharacterController>();
}
void Update () {
float x = Input.GetAxis("Horizontal");
float z = Input.GetAxis("Vertical");
if (controller.isGrounded)
{
direction = new Vector3(x, 0f, z);
direction = transform.TransformDirection(direction) * speed;
if (Input.GetKeyDown(KeyCode.Space) & controller.isGrounded)
{
direction = new Vector3(x, transform.position.y * jumpForce, z);
}
}
direction.y -= gravity * Time.deltaTime;
controller.Move(direction * Time.deltaTime);
}
}
подскажите почему редко прыгает при нажатии на пробел...