то же самое
This commit is contained in:
1 parent
090cdc9933
commit
ac99977be3
534 files changed
+36990
-48
No files matched your search
@@ -1,7 +1,62 @@
|
||||
namespace DefaultNamespace
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
public class PlayerNoise : MonoBehaviour
|
||||
{
|
||||
public class PlayerNoise
|
||||
[Header("Радиус шума от шагов")]
|
||||
public float sneakRadius = 3f;
|
||||
public float walkRadius = 8f;
|
||||
public float runRadius = 18f;
|
||||
|
||||
[Header("Настройки генерации")]
|
||||
public float stepInterval = 0.5f;
|
||||
private float stepTimer = 0f;
|
||||
|
||||
public GameObject wavePrefab;
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (Keyboard.current == null) return;
|
||||
|
||||
bool isMoving = Keyboard.current.wKey.isPressed ||
|
||||
Keyboard.current.aKey.isPressed ||
|
||||
Keyboard.current.sKey.isPressed ||
|
||||
Keyboard.current.dKey.isPressed;
|
||||
|
||||
if (isMoving)
|
||||
{
|
||||
stepTimer -= Time.deltaTime;
|
||||
if (stepTimer <= 0f)
|
||||
{
|
||||
EmitStepNoise();
|
||||
stepTimer = stepInterval;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
stepTimer = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
private void EmitStepNoise()
|
||||
{
|
||||
float currentRadius = walkRadius;
|
||||
|
||||
if (Keyboard.current.leftShiftKey.isPressed) currentRadius = runRadius;
|
||||
else if (Keyboard.current.leftCtrlKey.isPressed || Keyboard.current.cKey.isPressed) currentRadius = sneakRadius;
|
||||
|
||||
if (wavePrefab != null)
|
||||
{
|
||||
Vector3 footPosition = transform.position - new Vector3(0, transform.localScale.y / 2, 0);
|
||||
Instantiate(wavePrefab, footPosition, Quaternion.identity);
|
||||
}
|
||||
|
||||
Collider[] colliders = Physics.OverlapSphere(transform.position, currentRadius);
|
||||
|
||||
foreach (Collider hit in colliders)
|
||||
{
|
||||
BlindMutantAI mutant = hit.GetComponent<BlindMutantAI>();
|
||||
if (mutant != null) mutant.HearSound(transform.position);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user