Quantcast
Channel: Questions in topic: "invokerepeating"
Viewing all articles
Browse latest Browse all 220

Why isn't it switching the fireOn state to true

$
0
0

I want this script to make two objects switch which one is active.
The only thing that happens is that it says true in the debug thing. They are both in the same position in game just that `fireOn` starts deactivated.
I'm sorry if it's obvious but I'm new to unity.
public class FireActivateAndDeactivate : MonoBehaviour { private bool fireIsOn = false; [SerializeField] GameObject fireOn; [SerializeField] GameObject fireOff; [SerializeField] float speed = 2f; private void Start() { InvokeRepeating("TurnOnAndOff", speed, speed); } private void TurnOnAndOff() { if (fireIsOn == false){ fireOn.SetActive(true); fireOff.SetActive(false); fireIsOn = true; } if (fireIsOn == true) { fireOn.SetActive(false); fireOff.SetActive(true); fireIsOn = false; } Debug.Log(fireIsOn); } }

Viewing all articles
Browse latest Browse all 220


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>