|
|
@ -40,6 +40,8 @@ public class WaterController : MonoBehaviour { |
|
|
|
public void CreateWave(Vector3 point, float radius, float power){ |
|
|
|
|
|
|
|
//find all colliders within the wave distance
|
|
|
|
|
|
|
|
point.y = transform.position.y; |
|
|
|
StartCoroutine(waveController(point, radius, power, 2)); |
|
|
|
|
|
|
|
|
|
|
@ -48,7 +50,7 @@ public class WaterController : MonoBehaviour { |
|
|
|
|
|
|
|
#region Helper Functions
|
|
|
|
|
|
|
|
public IEnumerator waveController (Vector3 point, float radius, float power, float rippleTime) { |
|
|
|
private IEnumerator waveController (Vector3 point, float radius, float power, float rippleTime) { |
|
|
|
|
|
|
|
|
|
|
|
float elapsedTime = 0.0f; |
|
|
@ -89,7 +91,7 @@ public class WaterController : MonoBehaviour { |
|
|
|
//calls appropriate function if the object should interact with the water on enter
|
|
|
|
WaterObject waterInteraction = other.gameObject.GetComponent<WaterObject>(); |
|
|
|
if (waterInteraction != null) { |
|
|
|
waterInteraction.OnWaterEnter(gameObject); |
|
|
|
waterInteraction.OnWaterEnter(this); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
@ -105,7 +107,7 @@ public class WaterController : MonoBehaviour { |
|
|
|
float waveHeight = Mathf.PerlinNoise(waveCoords.x, waveCoords.y + waveOffset); |
|
|
|
|
|
|
|
|
|
|
|
waterInteraction.OnWaterStay(gameObject,waveHeight * maxWaveHeight); |
|
|
|
waterInteraction.OnWaterStay(this,waveHeight * maxWaveHeight); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
@ -114,7 +116,7 @@ public class WaterController : MonoBehaviour { |
|
|
|
//calls appropriate function if the object should interact with the water on exit
|
|
|
|
WaterObject waterInteraction = other.gameObject.GetComponent<WaterObject>(); |
|
|
|
if (waterInteraction != null) { |
|
|
|
waterInteraction.OnWaterExit(gameObject); |
|
|
|
waterInteraction.OnWaterExit(this); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|