Files
ZeroVR/ZeroPacientVR/Assets/Scripts/AudioDropRigidBody.cs
T
2022-04-18 19:17:20 +03:00

23 lines
493 B
C#

using FMODUnity;
using UnityEngine;
public class AudioDropRigidBody : MonoBehaviour
{
[SerializeField] public EventReference clip;
private void OnCollisionEnter(Collision other)
{
var magnitude = other.relativeVelocity.sqrMagnitude / 10f;
if (magnitude > 1f)
{
magnitude = 1f;
}
if (magnitude < 0.1f) return;
var pos = other.contacts[0].point;
RuntimeManager.PlayOneShot(clip.Guid, pos);
}
}