How can i check if a variable is 1? And how can i check if a key is pressed

ive been trying to find how to do the above but i didn’t really find a answer. i’m pretty beginner if you didn’t notice.

i will try to explain more what i’m trying to do

if variable is 1
{

then keep checking if key(& or 1 ) is pressed
{

}
}

You will accomplish each of those things ONE at a time, so pick one and start.

For reading the key, that’s easy: google for Youtube tutorials. If you can’t grasp that, NOTHING typed in this tiny text box will help either.

For comparing a variable to one, make the variable, compare it, print when it is one.

All of this stuff is done by DOING.

Just like this guy:

Imphenzia: How Did I Learn To Make Games:

Stop making excuses!

When something doesn’t work that means… time to start debugging!

By debugging you can find out exactly what your program is doing so you can fix it.

Use the above techniques to get the information you need in order to reason about what the problem is.

You can also use Debug.Log(...); statements to find out if any of your code is even running. Don’t assume it is.

Once you understand what the problem is, you may begin to reason about a solution to the problem.

Check if variable is 1

int A = 1;
if(A==1)
  Debug.Log(A); // logged console 1

Spawn projectile on down arrow pressed.

 if (Input.GetKey(KeyCode.DownArrow))
    Instantiate(projectile, transform.position, transform.rotation);

@discobot quote

:left_speech_bubble: To the timid and hesitating everything is impossible because it seems so. — Walter Scott

1 Like

it says: “tuple must contain two elements”

The variable one

Thank you i will try to do this in the future, but i was trying for like 2 hours believe it or not and i was just getting tired.

I see.

Below are variable

var a = 1;
float a =1;
int a=1;

Below are variable but using tuple

var (a, b) = (1, 1);
(int a, int b) = (1, 1);
(float a, float b) = (1, 1);