This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+1 vote

The docs arent explaining very well what this self keyword is, i just want to know what it does. I searched everything and theres nothing saying about it.

in Engine by (16 points)

1 Answer

+8 votes
Best answer

It's explained in the GDScript basics doc:

self - Refers to current class instance.

It serves essentially the same purpose as self or this in other object-oriented languages.

Specifically in GDScript, when used in a script, it's a reference to the object the script is attached to.

It's used whenever you need a reference to the current node, for example when connecting a signal to a local function:

func _ready():
    connect("some_signal", self, "some_function")

func some_function():
    # signal is now connected here
by (22,191 points)
selected by
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.