UP-Viagg-io/Viagg-io/Assets/Scripts/Audio/OnCollideSound.cs

22 lines
484 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FMODUnity;
public class OnCollideSound : MonoBehaviour
{
[SerializeField]
EventReference soundRef;
[SerializeField]
float minCollisionForce = 1.0f;
private void OnCollisionEnter(Collision collision)
{
if (collision.relativeVelocity.magnitude >= minCollisionForce)
{
RuntimeManager.PlayOneShot(soundRef, transform.position);
}
}
}