Я пытаюсь добавить переменную высоту прыжка в свой скрипт, но не могу понять, как это сделать.
Мне бы хотелось, чтобы кнопка прыжка была детализированной, чтобы чем дольше удерживается кнопка, тем выше может прыгнуть игрок. Если кто-нибудь знает, как этого можно добиться, изменив мой код, я был бы очень благодарен!
Код ниже:
private void JumpAndGravity()
{
if (Grounded)
{
// reset the fall timeout timer
_fallTimeoutDelta = FallTimeout;
// update animator if using character
if (_hasAnimator)
{
_animator.SetBool(_animIDJump, false);
// _animator.SetBool(_animIDFreeFall, false);
}
// stop our velocity dropping infinitely when grounded
if (_verticalVelocity < 0.0f)
{
_verticalVelocity = -2f;
}
// Jump
if (_input.jump && _jumpTimeoutDelta = 0.0f)
{
_jumpTimeoutDelta -= Time.deltaTime;
}
}
else
{
// reset the jump timeout timer
_jumpTimeoutDelta = JumpTimeout;
// fall timeout
if (_fallTimeoutDelta >= 0.0f)
{
_fallTimeoutDelta -= Time.deltaTime;
}
// if we are not grounded, do not jump
_input.jump = false;
}
// apply gravity over time if under terminal (multiply by delta time twice to linearly speed up over time)
if (_verticalVelocity < _terminalVelocity)
{
_verticalVelocity += Gravity * Time.deltaTime;
}
}
Подробнее здесь: https://stackoverflow.com/questions/784 ... ler-script
Как добавить переменную высоту прыжка в сценарий контроллера от третьего лица? ⇐ C#
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Мой код для камеры от третьего лица и движения вызывает ошибку, и я не знаю, почему
Anonymous » » в форуме C# - 0 Ответы
- 43 Просмотры
-
Последнее сообщение Anonymous
-