Getting Node2D position in C#

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

I’m trying to get the position of a Node2D as follows:

public override void _Ready()
Node2D pt = (Node2D)GetNode("../GetMe");
Vector2 coord = pt.get_global_position();

This fails to build with the error "Node2D does not contain a definition for ‘get_global_position()’. It looks like the docs in the editor list this as a getter function but I don’t see it listed on the online docs. I do see a member variable called global_position however. But when I try to do Vector2 coord = pt.get_global_position; I get the same error.

My object hierarchy looks like:

–KinematicBody2D (holds the script)
–Node2D “GetMe” (the object I’m trying to reference)
---- Sprite

So my questions are as follows:

  1. How do I get the position of a Node2D? What am I doing wrong here?
  2. Why does GetNode return a Node, when the object that I’m referencing is a Node2D?
:bust_in_silhouette: Reply From: nullsalad

ALRIGHT MY DUDES IT LOOKS LIKE IN C# GET_POS() AND OTHER GETTER METHODS CAN BE ACCESSED BY GOING Node2D.Position . Would like to see this reflected in the docs on the Node2D page rather than here API differences to GDScript — Godot Engine (3.0) documentation in English