//deactivate this lazer as well as a potential lazer that it activating public void DeActivateLazer() { m_Charged = false; m_LazerSystem.Stop(true, ParticleSystemStopBehavior.StopEmittingAndClear); GameObject baseCube = transform.GetChild(0).gameObject; baseCube.GetComponent <MeshRenderer>().material.color = Color.grey; // if lazer is activating another lazer then turn that lazer off if (m_ActivatedLazerConduit != null) { m_ActivatedLazerConduit.DeActivateLazer(); m_ActivatedLazerConduit = null; } }
private void RaycastLazer() { RaycastHit hit; if (Physics.Raycast(transform.position, transform.forward, out hit)) { //if ray hits a conduit if (hit.collider.gameObject.layer == LayerMask.NameToLayer("Lazer")) { LazerConduit conduit = hit.collider.gameObject.GetComponent <LazerConduit>(); if (conduit == null) { return; } //if true then successful activation and we can set activated conduit if (conduit.TryActivateLazer()) { m_ActivatedLazerConduit = conduit; } } //if ray is hitting the goal else if (hit.collider.gameObject.tag == "Goal") { hit.collider.gameObject.GetComponent <Goal>().MadeItGoal(); } //if you are not hitting a conduit else { if (m_ActivatedLazerConduit != null) { m_ActivatedLazerConduit.DeActivateLazer(); } } } //if connection between conduits breaks else { if (m_ActivatedLazerConduit != null) { m_ActivatedLazerConduit.DeActivateLazer(); } } }