How would you call an object?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By PixelatedIvan

I recently migrated to Godot from Gamemaker, and due to the lack of learning content compared to Gamemaker, the learning curve is rather rough. How would you call an object? Like if my player collides with it or if I want to edit a private variable?

:bust_in_silhouette: Reply From: kidscancode

There is a lot of Godot learning material available. One of the best places to start is the official documentation at Godot Docs – 3.0 branch — Godot Engine (3.0) documentation in English . Especially the Step by step section which includes a walk-through making a small, complete game. It is designed to show you how to do a lot of the most common tasks in Godot.

Objects can be referenced by their location in the scene tree, or depending on what you’re doing, object references are returned by various node functions. For example, if you’re using a KinematicBody2D, when it collides with another object it returns a collision object that includes a reference to the colliding body. It’s hard to answer your question specifically because there are so many possible situations.

One other comment: in GDScript there is no such thing as a private variable or method. Much like Python, you can access any property or method of an object, and the general convention is to use an underscore (ie, _varname) to indicate the property should be considered private.