test mesh
This commit is contained in:
@@ -60,9 +60,20 @@ public class charecter : MonoBehaviour
|
||||
}
|
||||
|
||||
PlayerInput.Instance.OnPickupPressed += TryPickupNearbyItem;
|
||||
PlayerInput.Instance.OnJumpPressed += () => { _jumpRequested = true; };
|
||||
PlayerInput.Instance.OnJumpPressed += OnJumpPressed;
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
if (PlayerInput.Instance != null)
|
||||
{
|
||||
PlayerInput.Instance.OnPickupPressed -= TryPickupNearbyItem;
|
||||
PlayerInput.Instance.OnJumpPressed -= OnJumpPressed;
|
||||
}
|
||||
}
|
||||
|
||||
void OnJumpPressed() => _jumpRequested = true;
|
||||
|
||||
void Update()
|
||||
{
|
||||
HandleLook();
|
||||
@@ -85,14 +96,19 @@ public class charecter : MonoBehaviour
|
||||
|
||||
foreach (var col in colliders)
|
||||
{
|
||||
var worldItem = col.GetComponent<WorldItem>();
|
||||
// Ищем WorldItem на коллайдере ИЛИ на любом родителе —
|
||||
// чтобы дочерние меши (Visual, default и т.д.) тоже находили своего владельца
|
||||
var worldItem = col.GetComponentInParent<WorldItem>();
|
||||
if (worldItem == null) continue;
|
||||
|
||||
// Дедупликация: пропускаем если этот WorldItem уже учтён через другой коллайдер
|
||||
if (worldItem == closestItem) continue;
|
||||
|
||||
float dist = Vector3.Distance(transform.position, worldItem.transform.position);
|
||||
if (dist < closestDist && dist <= worldItem.interactRange)
|
||||
{
|
||||
closestDist = dist;
|
||||
closestItem = worldItem;
|
||||
closestDist = dist;
|
||||
closestItem = worldItem;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +159,7 @@ public class charecter : MonoBehaviour
|
||||
if (_jumpRequested && !isCrouching)
|
||||
{
|
||||
_verticalVelocity = Mathf.Sqrt(jumpHeight * -2f * gravity);
|
||||
_anim?.SetTrigger(HashJump);
|
||||
if (_anim != null) _anim.SetTrigger(HashJump);
|
||||
}
|
||||
_jumpRequested = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user