void Update() { float distFromPrev = Vector2.Distance(previousFootstepPos, rigidbody2D.position); if (distFromPrev > stepDistance) { previousFootstepPos = rigidbody2D.position; float speed = rigidbody2D.velocity.magnitude; float radius = maxSoundRadius * Mathf.Clamp01(speed / speedForMaxSoundRadius); soundEmitter.EmitSound(radius); } if (rigidbody2D.velocity.magnitude > 0.1f) { if (!footstepSource.isPlaying) { footstepSource.Play(); } } else if (footstepSource.isPlaying) { footstepSource.Stop(); } }
public void CmdPlayerEmitSound() { _soundEmitter.transform.position = transform.position; _soundEmitter.EmitSound(); RpcPlayTauntSound(); }