public void MoveInDirection(Vector3 direction, float speedFraction) { GetComponent <ActionScheduler>().StartAction(this); if (speedFraction > 1) { if (energy.CanConsumeEnergy(energyToSprint)) { energy.ConsumeEnergy(energyToSprint); } else { speedFraction = 1; } } if (jumper.IsJumping()) { jumper.MoveWhileJumping(direction, maxSpeed * Mathf.Max(0, speedFraction), elapsedRotationTime); } else { navMeshAgent.destination = transform.position + direction; navMeshAgent.speed = maxSpeed * Mathf.Max(0, speedFraction); navMeshAgent.isStopped = false; } }
public void Jump() { if (isJumping) { return; } if (!energy.CanConsumeEnergy(energyToJump)) { return; } GetComponent <ActionScheduler>().StartAction(this); energy.ConsumeEnergy(energyToJump); navMeshAgent.enabled = false; rbody.isKinematic = false; rbody.useGravity = true; cachedPosition = transform.position; transform.Translate(0, initialBoost, 0); rbody.AddForce(0, jumpForce, 0, ForceMode.Impulse); isJumping = true; GetComponent <Animator>().SetTrigger("jump"); }