test commit
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class VolumetricAudio : MonoBehaviour
|
||||
{
|
||||
// old ass "pingvin mod v2" code LOL
|
||||
public float fully2DDistance = 2f;
|
||||
public float fully3DDistance = 10f;
|
||||
public AudioSource audioSource;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (audioSource == null)
|
||||
audioSource = GetComponent<AudioSource>();
|
||||
}
|
||||
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
Gizmos.color = new Color(1, 0, 0, 0.25f);
|
||||
Gizmos.DrawWireSphere(this.transform.position, fully3DDistance);
|
||||
Gizmos.color = new Color(0, 1, 0, 0.25f);
|
||||
Gizmos.DrawWireSphere(this.transform.position, fully2DDistance);
|
||||
Gizmos.color = Color.white;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (!Camera.main)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
float distance = Vector3.Distance(Camera.main.transform.position, transform.position);
|
||||
|
||||
//audioSource.spatialBlend = Mathf.Lerp(audioSource.spatialBlend, Mathf.InverseLerp(fully2DDistance, fully3DDistance, distance), Time.deltaTime * 10f);
|
||||
audioSource.spatialBlend = Mathf.InverseLerp(fully2DDistance, fully3DDistance, distance);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user