using UnityEngine; using UnityEngine.VFX; public class TriggerSplash : MonoBehaviour { public GameObject prefab; private float previousNormalizedHeight = -1f; private Rigidbody rigibodyComponent; private void OnEnable() { rigibodyComponent = GetComponent(); } private void Update() { float normalizedHeightOfSphereBelowSurface = GetComponent().GetNormalizedHeightOfSphereBelowSurface(); if (normalizedHeightOfSphereBelowSurface > 0f && previousNormalizedHeight <= 0f && PoolManager.Instances[PoolManager.InstanceType.Splash] != null) { GameObject nextAvailable = PoolManager.Instances[PoolManager.InstanceType.Splash].getNextAvailable(); if (nextAvailable != null) { nextAvailable.transform.position = GetComponent().GetCurrentWaterPosition(); VisualEffect component = nextAvailable.GetComponent(); component.SetFloat("Splash Radius", GetComponent().sphereRadiusApproximation); component.SetVector3("Velocity", rigibodyComponent.linearVelocity); nextAvailable.SetActive(value: true); component.Play(); } } previousNormalizedHeight = normalizedHeightOfSphereBelowSurface; } }