0 votes

Hi everyone. I want to know what exactly does this symbol do ()

Give me explanation about () please.

in Engine by (18 points)

1 Answer

+1 vote

When i was a total noob it irritated me too, nobody talks about it in any tutorial, it is so confusing :)

parentheses after function name are place where You input arguments. For example :

move_toward(vec2(1,2))           draw_square(a,b)

When functions ends with empty parentheses, than it simply intakes no arguments. There are a lot of such functions in Godot, they do usefull thing without using any user input, like:

queue_free()           ready()

But there are also a lot of functions, that don't require any argument, but You MAY PASS some into parentheses and function will do additional things. You will get used to reading about every method and function in documentation to get the best fo them.

When You create your own custom function You also choose if parentheses are empty or not. For example :

func doubler( number ) :
    return number * 2

This function multiplies any number by 2. Every time it is called it will require caller to input any argument in parenthesis, and it will multiply it by 2. It cannot be called with empty parenthesis, because it will not know what to multiply.

by (7,925 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.