From 1794e20caf5ed08a205b5b5d59dd0722a19022b8 Mon Sep 17 00:00:00 2001 From: Joshua Reason Date: Sun, 22 Jan 2017 11:54:38 +1100 Subject: [PATCH] ripples now based on water size --- .../Assets/Scripts/WaterController.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/IronToad_UnityProject/Assets/Scripts/WaterController.cs b/IronToad_UnityProject/Assets/Scripts/WaterController.cs index 48d504f..cd1f2d2 100644 --- a/IronToad_UnityProject/Assets/Scripts/WaterController.cs +++ b/IronToad_UnityProject/Assets/Scripts/WaterController.cs @@ -13,6 +13,8 @@ public class WaterController : MonoBehaviour { public float waveSpeed = 1; public float maxWaveHeight = 2; + private readonly float scaleConstant = 50f; + public GameObject rippleEffect; #region Unity Functions @@ -48,8 +50,15 @@ public class WaterController : MonoBehaviour { pos.y += 1; Quaternion rot = Quaternion.Euler(-90, 0, 0); - if (rippleEffect != null) - Destroy(Instantiate(rippleEffect, pos, rot), 4); + if (rippleEffect != null) { + GameObject ripple = Instantiate(rippleEffect, pos, rot); + + Vector3 scale = Vector3.one * radius / scaleConstant; + ripple.transform.localScale = scale; + + Destroy(ripple, 4); + + } Collider[] colliders = Physics.OverlapSphere(point, radius); foreach (Collider hit in colliders) {