29 lines
687 B
C#
29 lines
687 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using BITKit.Sensors;
|
|
namespace BITKit.Entities
|
|
{
|
|
public class EntityAudioObject : EntityComponent, IAudioObject
|
|
{
|
|
float volume;
|
|
public override void OnStart()
|
|
{
|
|
entity.AddListener<AudioSO>(OnAuioSO);
|
|
}
|
|
public override void OnFixedUpdate(float deltaTime)
|
|
{
|
|
volume = Mathf.Lerp(volume, 0, deltaTime);
|
|
}
|
|
public float GetVolume()
|
|
{
|
|
return volume;
|
|
}
|
|
void OnAuioSO(AudioSO so)
|
|
{
|
|
if (so.distance > volume)
|
|
volume = so.distance;
|
|
}
|
|
}
|
|
}
|