I'm making a 2D game, and I want to change a variable's value when I click one of my sprites. How should I do that??

It’s a game and you click a game object to control it. I definitely can’t just make it into a UI element. What’s the best way to detect a click on a game object???

I have not tried that. I added the code to the last response if you would like to take a look at what I have so far

2 Answers

2

I dont really understand your question but i guess you want something that works with mouse…

So…
Try OnMouseDown() Function

The best way to detect a mouse pick is using the Physics.RayCast(), obviously you need to have a Game Object with a collider (no matter what type) and a rigid body this two components attached to it (for your safety turn the Is Kinematic on), for more reference check the documentation, cheers.

Update - I figured out the wait time for 4 seconds code and it is working! There is a 4 second delay on start of the game, but there is one issue. The countdown is also paused and starts playing after the 4 seconds. How do I make the countdown play during the 4 second wait?