синхрон шгов с шейдером
This commit is contained in:
1 parent
9245409fc9
commit
7fba61f7a0
5 files changed
+268
-39
No files matched your search
@@ -1,4 +1,4 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
public class PlayerNoise : MonoBehaviour
|
||||
@@ -14,8 +14,17 @@ public class PlayerNoise : MonoBehaviour
|
||||
|
||||
public GameObject wavePrefab;
|
||||
|
||||
[Header("Синхронизация")]
|
||||
[Tooltip("Если включено и на объекте есть EchoTrigger, генерация шума шагов синхронизируется с анимацией персонажа через EchoTrigger")]
|
||||
public bool syncWithEchoTrigger = true;
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (syncWithEchoTrigger && GetComponent<EchoTrigger>() != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Keyboard.current == null) return;
|
||||
|
||||
bool isMoving = Keyboard.current.wKey.isPressed ||
|
||||
@@ -38,25 +47,33 @@ public class PlayerNoise : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
private void EmitStepNoise()
|
||||
public void EmitFootstep(Vector3 footPosition, float radius)
|
||||
{
|
||||
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);
|
||||
Collider[] colliders = Physics.OverlapSphere(footPosition, radius);
|
||||
|
||||
foreach (Collider hit in colliders)
|
||||
{
|
||||
BlindMutantAI mutant = hit.GetComponent<BlindMutantAI>();
|
||||
if (mutant != null) mutant.HearSound(transform.position);
|
||||
if (mutant != null) mutant.HearSound(footPosition);
|
||||
}
|
||||
}
|
||||
|
||||
private void EmitStepNoise()
|
||||
{
|
||||
float currentRadius = walkRadius;
|
||||
|
||||
if (Keyboard.current != null)
|
||||
{
|
||||
if (Keyboard.current.leftShiftKey.isPressed) currentRadius = runRadius;
|
||||
else if (Keyboard.current.leftCtrlKey.isPressed || Keyboard.current.cKey.isPressed) currentRadius = sneakRadius;
|
||||
}
|
||||
|
||||
Vector3 footPosition = transform.position - new Vector3(0, transform.localScale.y / 2, 0);
|
||||
EmitFootstep(footPosition, currentRadius);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user