浏览代码

Fixed an issue regarding player jump not getting stopped by a collision from above

/main
Quickz 4 年前
当前提交
6738e6e0
共有 1 个文件被更改,包括 22 次插入0 次删除
  1. 22
      UOP1_Project/Assets/Scripts/Characters/Character.cs

22
UOP1_Project/Assets/Scripts/Characters/Character.cs


turnSmoothTime);
}
}
private void OnControllerColliderHit(ControllerColliderHit hit)
{
if (isJumping)
{
// Making sure the collision is near the top of the head
float permittedDistance = characterController.radius / 2f;
float topPositionY = transform.position.y + characterController.height;
float distance = Mathf.Abs(hit.point.y - topPositionY);
if (distance <= permittedDistance)
{
// Stopping any upwards movement
// and having the player fall back down
isJumping = false;
gravityContributionMultiplier = 1f;
verticalMovement = 0f;
}
}
}
//---- COMMANDS ISSUED BY OTHER SCRIPTS ----

正在加载...
取消
保存