Get Child Returning Null

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

Can somebody tell my what’s wrong with this?

func Get_Target():
	var target: Vector3 = ai_path.get_child(ai_current_pos).position
	return target

It says: Invalid get index ‘position’ (on base: ‘Position3D’).

I don’t know why it returns null, the variable ai_path is a reference to the path root node (“…/AI_Path”) and the get_child should get the first child since the variable ai_current_pos is set to 0;

Node Tree:
(Root) World
    - ...
    - AI_Path
         - Node1
         - Node2

are you SURE ai_current_pos is 0?

whiteshampoo | 2020-07-20 13:18

yep, but i think i solved my problem using translation instead of position.

StrikerSVX | 2020-07-20 13:55

:bust_in_silhouette: Reply From: klaas

The error states → there is no property position in the object of type “Position3D”

Use the property translation wich is implemented in Spatial wich Position3D extends from.