- Home /
Question by
DubstepDragon · Mar 03, 2013 at 12:32 PM ·
intconvertbool
Changing a bool when an int reaches a specific number...
I need to know how to change the state of a bool once an int reaches a specific number. Here is my current code:
if(killCounter = 10) {
weapon.hasWorm = false;
weapon.hasDazzler = true;
}
I am currently getting this error:
Assets/Scripts/Weapons and Pickups/killCount.cs(16,17):
error CS0029: Cannot implicitly convert type `int' to `bool'
I need urgent assistance if possible.
Thanks in advance!
Comment
Best Answer
Answer by Khada · Mar 03, 2013 at 12:44 PM
Just change it to:
//note the comparison operator is two assignment operators '='
if(killCounter == 10)
{
//code
}
EDIT: I should really elaborate. A single '=' is for assigning a value to something, whist a double '=' is for comparing two objects (returns true/false).
You are so awesome dude... I cannot believe your level of epicosity...
Your answer
Follow this Question
Related Questions
Convert type `float' to `bool', Load 1 Answer
convert string to int 0 Answers
A node in a childnode? 1 Answer
Getting Error Object reference not set to an instance of an object 1 Answer
I don't have ScrollRect in Unity 1 Answer