How to get the position of a child of a node?

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

I’ve already tried using GetParent().GetNodeOrNull<Position2D>("Position2D"), but when I try to use Position or GlobalPosition I get this error:

E 0:00:01.635 void Player.Fire(): System.NullReferenceException:
Object reference not set to an instance of an object. <C++ Error>
Unhandled exception <C++ source>
C:\Users\dulou\OneDrive\Documents\Game 001\Body\Player.cs:20 @ void
Player.Fire()() Player.cs:20 @ void Player.Fire()()
Player.cs:44 @ void Player._PhysicsProcess(Single )()

and this keeps happening in any kind of function or method

How is your scene setup?

magicalogic | 2021-06-09 05:39

is basically:

Player(KinematicBody2D)
—Sprite
—CollisionShape2D
—Position2D

CarlitosCUeba | 2021-06-10 00:31

:bust_in_silhouette: Reply From: Metaponta

maybe try out

get_parent().get_node("nodename").Position

oh wait sry ur using c#, forget my answer xd

anyway thank you xD

CarlitosCUeba | 2021-06-10 00:21