Marek Fix
This commit is contained in:
@@ -86,6 +86,7 @@ namespace MegaKoop.Game
|
||||
{
|
||||
EnsureAnimatorReference();
|
||||
InitializeAnimatorHashes();
|
||||
SnapToGroundImmediate();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
@@ -120,6 +121,31 @@ namespace MegaKoop.Game
|
||||
UpdateAnimator();
|
||||
}
|
||||
|
||||
private void SnapToGroundImmediate()
|
||||
{
|
||||
if (characterController == null)
|
||||
{
|
||||
characterController = GetComponent<UnityEngine.CharacterController>();
|
||||
}
|
||||
|
||||
Vector3 pos = transform.position;
|
||||
float up = 2.5f;
|
||||
float down = 10f;
|
||||
float radius = characterController != null ? characterController.radius : 0.25f;
|
||||
Vector3 origin = pos + Vector3.up * up;
|
||||
if (Physics.SphereCast(origin, Mathf.Max(0.05f, radius * 0.9f), Vector3.down, out RaycastHit hit, up + down, ~0, QueryTriggerInteraction.Ignore))
|
||||
{
|
||||
float centerY = characterController != null ? characterController.center.y : 0f;
|
||||
float height = characterController != null ? characterController.height : 2f;
|
||||
float bottomToCenter = Mathf.Max(radius, height * 0.5f) - radius;
|
||||
float targetY = hit.point.y + bottomToCenter - centerY + 0.02f;
|
||||
transform.position = new Vector3(pos.x, targetY, pos.z);
|
||||
isGrounded = true;
|
||||
verticalVelocity = groundedGravity;
|
||||
lastTimeGrounded = Time.time;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetInputSource(MegaKoop.Game.Networking.ICharacterInputSource source)
|
||||
{
|
||||
inputSource = source;
|
||||
|
||||
Reference in New Issue
Block a user