From 5160c15cf4ee995192875ca03a486dec8ff76619 Mon Sep 17 00:00:00 2001 From: Matthew Blakoe Date: Thu, 23 Jul 2020 23:08:30 +0100 Subject: [PATCH] Update TractorBeam.cs --- .../Interaction Definitions/TractorBeam.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/Functional Definitions/Interaction Definitions/TractorBeam.cs b/Assets/Scripts/Functional Definitions/Interaction Definitions/TractorBeam.cs index c7a5313fc..c2d584358 100644 --- a/Assets/Scripts/Functional Definitions/Interaction Definitions/TractorBeam.cs +++ b/Assets/Scripts/Functional Definitions/Interaction Definitions/TractorBeam.cs @@ -17,6 +17,7 @@ public class TractorBeam : MonoBehaviour protected float energyPickupSpeed = 61.0f; // Disabled for now D: (60*FixedDeltatime = 10) Energy pickup rate scale for future hard/easy gamemodes and AI balancing only. public bool initialized; private bool energyEnabled = true; + private GameObject tractorBeamPrefab; public void SetEnergyEnabled(bool val) { energyEnabled = val; @@ -36,7 +37,7 @@ public void BuildTractor() { targetGlow.gameObject.SetActive(false); GameObject childObject = new GameObject(); - // childObject.transform.SetParent(transform, false); + //childObject.transform.SetParent(transform, false); Unity ignores sorting layers if uncommented lineRenderer = childObject.AddComponent(); lineRenderer.material = tractorMaterial; lineRenderer.startWidth = 0.1F; @@ -46,6 +47,7 @@ public void BuildTractor() { lineRenderer.sortingOrder = 1; lineRenderer.sortingLayerName = "Projectiles"; childObject.name = "TractorBeam"; + tractorBeamPrefab = childObject; initialized = true; } private void Update() { @@ -156,8 +158,10 @@ protected void OnDestroy() { if(coreGlow) Destroy(coreGlow.gameObject); - if (targetGlow) + if(targetGlow) Destroy(targetGlow.gameObject); + if(tractorBeamPrefab) + Destroy(tractorBeamPrefab); } bool forcedTargetHadDraggable = false;