how does _get work?

Zodiacx10Zodiacx10 Posts: 3Member

when you do get_something and the something is a value, shouldnt get return whatever the current value is? why does it only return the value it had when it started? even if its in process func it doesnt update


  • MegalomaniakMegalomaniak Posts: 2,649Admin

    Getters work together with setters. the value it gets should be updated by a setter.

  • TwistedTwiglegTwistedTwigleg Posts: 2,663Admin

    Welcome to the forums @Zodiacx10!

    The _get and _set functions are primarily used with the get_property_list function in the C++ code, as the properties introduced through said function rely on both _get and _set. In _get, the second argument will be overridden with whatever the value has been retrieved, based on what I know of the C++ code.
    For GDScript/C#, it is probably better to either access the properties directly, or use the getter/setter functions designed specifically for the property you are wanting.

  • Zodiacx10Zodiacx10 Posts: 3Member

    how does that work for get_collision_point on raycast where there is no set_collision_point?

  • MegalomaniakMegalomaniak Posts: 2,649Admin

    In a more specialized situation like that I'd expect the physics engine to be the one setting that. And naturally I'd expect it to be set only when there is a collision.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file