diff --git a/Assets/Scripts/Blood/BloodComputeShader.cs b/Assets/Scripts/Blood/BloodComputeShader.cs index a26d038..2e3b021 100644 --- a/Assets/Scripts/Blood/BloodComputeShader.cs +++ b/Assets/Scripts/Blood/BloodComputeShader.cs @@ -3,6 +3,7 @@ using System.Collections; using System.Collections.Generic; using ComputeShaderUtility; using UnityEngine; +using UnityEngine.Assertions; using UnityEngine.Rendering; public struct Droplet @@ -61,6 +62,8 @@ public class BloodComputeShader : MonoBehaviour [SerializeField] uint bufferLookPointer = 0; + private bool gameHasStarted = false; + private void Awake() { if (Instance != null) @@ -137,12 +140,17 @@ public class BloodComputeShader : MonoBehaviour { mop1 = players[0].GetComponent(); mop2 = players[1].GetComponent(); + + gameHasStarted = true; } // Update is called once per frame void Update() { - if (mop1 == null || mop2 == null) return; + if (!gameHasStarted) return; + + Assert.IsNotNull(mop1); + Assert.IsNotNull(mop2); bloodCompute.SetFloat("deltaTime", Time.deltaTime); bloodCompute.SetInt("numParticles", numParticles);