I don't know why this should be a problem. Just do what Mertle told you to do.
"Who the heck is Mertle?" you might ask. "I don't know anyone by that name!"
That's exactly what the compiler is telling you:
"not declared in the current scope"
is the compiler's way of saying "I don't know who you're talking about. Who is this ui
person who can tell me about .right
? You haven't introduced us yet!"
You've used a new name that you haven't introduced before in this conversation (scope), so the compiler has no idea who you mean.
In fact, ui
is not an object that the compiler can ask for a .right
member.
"ui.right"
is a string of text that you want it to pass to the is_action_pressed
function as-is.
To pass a string, you must put double-quotation marks around it, so the compiler knows to treat it as a blob of plain text, not an expression or variable to parse and evaluate.
So, replace this with:
if Input.is_action_pressed("ui_right"):
...as shown in the Godot documentation on Input events.
As a general rule, when following a programming guide, every character is important. You can't leave any out. So check your examples carefully to make sure you typed out everything. The capitalization of Input
is important too!