Forum Discussion
DillonRobinson
12 years agoHonored Guest
Comfortable forced crouching?
Hello guys, I have a question here. As I near the end of my next project, I have an idea. In a couple areas throughout my diorama game, I have placed some chairs. I disabled their collision boxes, ...
drash
12 years agoHeroic Explorer
Thanks for sharing your code for this!
When you do if(forceCrouch = true), it's actually setting forceCrouch to true, and then checking if it's true. This is because of the single equal sign (assignment operator). To simply check equivalence, use a double equal sign instead. The reason it works without the "= true" is because everything inside the if's parentheses are evaluated to a true/false condition.
"DillonRobinson" wrote:
Wow! So I was using if (forceCrouch = true) {} else {}
All I did was remove the "=true" and it started working! Very bizarre. I could have sworn they both meant the same thing.
When you do if(forceCrouch = true), it's actually setting forceCrouch to true, and then checking if it's true. This is because of the single equal sign (assignment operator). To simply check equivalence, use a double equal sign instead. The reason it works without the "= true" is because everything inside the if's parentheses are evaluated to a true/false condition.
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 8 months ago
- 3 years ago