Skip to main content
5 votes

If statements seem to act as though the condition is always true

Remove the semicolon at the end of your if statements. That semicolon tells the compiler "I'm done with this" and whatever comes next is a new, unrelated statement So this (note semicolon at the end ...
DMGregory's user avatar
  • 141k
2 votes
Accepted

Animator from another gameobject keeps disappearing from script on play

As is usually the case, this is happening because you told Unity that's what you wanted to happen. This block says: ...
DMGregory's user avatar
  • 141k
2 votes

Count the number of Vulnerable and Invulnerable crops

Alternatively, you can use the Linq lambda like so: ...
Stephan's user avatar
  • 1,738
2 votes
Accepted

Count the number of Vulnerable and Invulnerable crops

Is there something wrong with a simple for loop? ...
Alex F's user avatar
  • 425
2 votes
Accepted

How to save boolean to player prefs in Unity?

It is because you are setting PlayerPref in Update method. Now, you start your game, ant object's values are reset to initial value. So music object becomes null and musicOn becomes true (because you ...
eLTomis's user avatar
  • 470
1 vote
Accepted

Need help accessing booleans from other script Unity3D

As DMGregory observed, it seems like your root issue is that you are setting dead to false each time you spawn a platform: ...
Kevin's user avatar
  • 6,976
1 vote

How to use a boolean to activate every item with the same tag?

FindGameObjectsWithTag only finds already active GameObjects. From the documentation: Returns an array of active GameObjects tagged ...
Ed Marty's user avatar
  • 5,259
1 vote
Accepted

In unity C#, why use the .SetBool(booleanname, boolean) command when you could just write 'booleanname = true'?

These two lines do different things. animator.SetBool("isRunning", true) This sets The Animator's isRunning parameter to true ...
DMGregory's user avatar
  • 141k

Only top scored, non community-wiki answers of a minimum length are eligible