Is changing a true/false bool possible from a different script?

I am fine tuning my Laser Defender project to include features outside to the lecture. I have been successful in implementing what I want, for the most part. For one, I’ve given up on trying to implement since I can’t seem to find a solution. For the one below, I am still hoping a solution can be found.

One of the features is an upgradeable player ship. I have the coding completed to upgrade my ship. And downgrade it when hit. But, now I have an issue.

I have a PowerupSpawner.cs that uses a do {coroutine} while looping to spawn ship upgrade power-ups. When the ship has reached it’s maximum upgrade level, I need the upgrade power-ups to stop spawning until the ship level gets downgraded by taking a hit.

Theoretically, I want to toggle looping ‘off.’ And, then back ‘on.’ I need this toggle to be made in the Player.cs. I’ve searched the Unity manual and googled the scenario. I can’t find a solution that actually works.

Am I not thinking in the right direction? Or is what I am trying to accomplish not possible to begin with?

1 Like

@J_Happ I hope this link helps you with your issue

https://forum.unity.com/threads/changing-the-value-of-a-bool-from-a-different-script.255525/

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms