My variable script is not working can anyone help

Hi i am new to Godot and i was trying to use a variable but it didn’t work when i added the if. Here is the code:

var direction = Input.get_vector(“left”, “right”, “up”, “down”)

if direction.x == 0 and direction.y == 0:

can anyone help me figure out what is wrong?

What didn’t work? What did you expect to happen vs what really happened?

Make sure to make your code with proper formatting, and a little more code too please.

can some one please just tell me what to do to fix it

No, you need to give more information. It’s impossible for us to know what is wrong so it’s impossible to fix it succinctly.

1 Like

If that is literally all your code, then:

  • It needs to be inside a function (probably the _process function)
  • Something needs to happen in the if statement

Something like:

func _process(delta):
    var direction = Input.get_vector(“left”, “right”, “up”, “down”)
    if direction.x == 0 and direction.y == 0:
        print("Direction is (0, 0)")

But as @gertkeno said, it’s hard to help more without you giving more information.

3 Likes