void DetectItems() { if (Input.GetButtonUp("Submit")) { if (Physics.Raycast(myTransform.position, myTransform.forward, out hit, range, detectionLayer)) { Vector3 next = NextRoom(hit.transform.position); if (!generator.HasCreated(next)) { generator.CreateRoom(next, generator.currentLevel); } hit.transform.gameObject.GetComponent <Door>().Toggle(); } } if (Input.GetButtonUp("Fire1")) { Instantiate(shot, myTransform.position + myTransform.forward, Quaternion.FromToRotation(Vector3.forward, myTransform.forward)); if (Physics.Raycast(myTransform.position, myTransform.forward, out hit, range * 10, shootStuff)) { Floid enemy = hit.transform.gameObject.GetComponent <Floid>(); Rotator heart = hit.transform.gameObject.GetComponent <Rotator>(); if (enemy != null) { enemy.Explode(); } else if (heart != null) { heart.Heal(); } } } }