- Home /
Checking bool in a If statement
Hello. Could someone help me? It's a simle thing but I have no idea why it's getting an error.
I'm trying to check some bool in a If statement and then call a function if these bool are ture but I'm getting a weird error
"error CS0019: Operator &&' cannot be applied to operands of type
method group' and `bool'"
What does that mean?
This is the code
void ActivatePlayer(){
if (rbPlayer.IsSleeping && canShoot){
SetMyTurnOn ();
}
show us the whole code, prob IsSleeping is a method
public bool canShoot; public bool matchEnded; public PlayerController playerController; public Rigidbody rbPlayer; public UIController uiController;
// Use this for initialization
void Start () {
matchEnded = false;
canShoot = true;
}
void LateUpdate () {
ActivatePlayer ();
}
void ActivatePlayer(){
if (rbPlayer.IsSleeping && canShoot){
Set$$anonymous$$yTurnOn ();
}
}
I tried this
void ActivatePlayer(){
bool isSleeping = rbPlayer.IsSleeping;
if (isSleeping && canShoot){
Set$$anonymous$$yTurnOn ();
}
}
But got the same error.
Answer by sisse008 · Dec 03, 2017 at 01:55 PM
IsSleeping is a variable or a function? if function it should be: rbPlayer.IsSleeping()
Answer by Ahsenhein · Dec 03, 2017 at 01:58 PM
Yeah Just logged in to say I got the problem now.
void ActivatePlayer(){
if (rbPlayer.IsSleeping() && canShoot){
SetMyTurnOn ();
}
}
Thanks guys.
Your answer
Follow this Question
Related Questions
Using bool function with parameters 1 Answer
Making a level up button., 2 Answers
How to use the Regex class to check for string with case insensitive? 1 Answer
How Do I check if a Bool was True a few moments ago 2 Answers
How do you trigger a collider to become enabled after the player collider isn't touching it anymore? 4 Answers