Questions tagged [boolean]
A type of data with only two possible values, usually "true" or "false".
18 questions
0
votes
0
answers
692
views
Booleans cannot be changed between scripts in Unity
In my game there is a game manager that interacts with all players and is able to change whether a player is actionable by accessing their script. However, the Game manager script simply refused to ...
0
votes
1
answer
104
views
Need help accessing booleans from other script Unity3D
I'm making an endless runner game where platforms move towards the player so it makes it seem like the player is running across them. I'm trying to make it so that when the player dies, the platforms ...
0
votes
2
answers
2k
views
How to save boolean to player prefs in Unity?
I'm making a player settings thing where the user can turn off or turn on the game music by clicking buttons. I had this script below and everything was working fine.
...
0
votes
1
answer
71
views
How to use a boolean to activate every item with the same tag?
I've been really stuck on this one and need some help.
I've got some accessories for my player, and my goal is to have a collider,
with the script attached. When the player walks into the script, the ...
0
votes
1
answer
1k
views
In unity C#, why use the .SetBool(booleanname, boolean) command when you could just write 'booleanname = true'?
I noticed on a tutorial for unity someone used the code:
private Animator animator;
private bool isRunning = false;
While further on, did:
...
0
votes
2
answers
85
views
How do I tag an empty space for an 'InAir' Boolean?
I've been working with my game's settings to get the perfect jump height, gravity and movement that suits the player, however my problem is my player essentially floats back down to the ground, when I ...
0
votes
1
answer
172
views
Animator from another gameobject keeps disappearing from script on play
I am working on a gun script and it worked fine until earlier today when I made a change to the script and it stopped working. I put it back, but for some reason now the animator object attached to ...
0
votes
3
answers
154
views
Count the number of Vulnerable and Invulnerable crops
I have this code that counts how many GameObjects (crops) in the scene
GameObject[] crops;
and the code to get the health component of each crops
...
0
votes
1
answer
485
views
If statements seem to act as though the condition is always true
I have other scripts in the same project using boolean if statements that work fine, but I've tried multiple methods of testing if the if statements below are working and none of them worked!
I don't ...
0
votes
1
answer
877
views
Unity 5 2d Magnet Power Up
I made a car game with coins and power up but i wrote a code for magnet power up but in start work fine but after i get power up magnet all coin in surface i collect but after this don`t spawn coin ...
0
votes
1
answer
36
views
Issues with Toggle
hope you're all good..
I'm struggling with a simple toggle for inverting Y axis..
What i have works for my first scene but i'm trying to keep this setting through all scenes, hence why the script ...
3
votes
1
answer
2k
views
How do I get diagonal 3d movement when two buttons are pressed?
I have a model moving using root motion. Currently, it's moving in 4 directions; Forward, Backward, Right, and Left.
Now, I want to make the character move in 45 degrees. I made a chart to understand ...
0
votes
1
answer
242
views
Playing an animation all the way through with one quick keypress with Mechanim Unity
I have an if statement inside of the Update function that is only called if three other conditions are met. The problem is that right now the function sets a boolean to true which causes the animation ...
-2
votes
1
answer
55
views
Unity3D: Entering a trigger disables a few bools for no reason
I'm trying to make it so when an object enters a collider with the tag "Down" a single boolean turns false, but the problem is that more than one booleans(canGoUp, canGoLeft, canGoRight) are turning ...
14
votes
2
answers
32k
views
Is there a random command for Boolean variables in Unity C# [closed]
Can you randomly choose a Boolean's value in Unity C#. I tried random.range, but it only works with floats. Here is an example of what I'm trying to do:
...
1
vote
0
answers
52
views
How to save characters in iOS game app
BOOL = GREENIE, UIButton =GREEN. When I click the GREEN button, I coded that now you play as GREENIE character. However, I don't know how to code it that the game always remember that the I clicked on ...
3
votes
1
answer
777
views
If-clause in GLSL
I read a few thing about, that in GLSL both sides of the if-clause is executed, so do you have any idea for a workaround for this one:
...
0
votes
3
answers
404
views
Drawing sprites only under certain conditions - alternatives to using 'if statements'?
Within my game (which is Java/Android), I wish to draw a sprite only under certain conditions, so up until now, I've been using if statements to accomplish this. Something like so:
...