GetNode<Camera3D> returns null , also when i make it unique in scene or full path

Godot Version

4.2

Question

Hello
Im able to retrieve all nodes in the scene but i have problem to retrieve the Camera3D
That is attached to Player “Nek” Node3D
What ever i do i retrieve null .

This is my hierarchy:
image

The code below all nodes are initiated right except the Camera3D they are both null

   	private Node3D Head;
   	private Node3D Nek;
	private CollisionShape3D StandingCollisionShape3D;
   	private CollisionShape3D CrounchCollisionShape3D;
	private RayCast3D PlayerRayCast3D;
	private Camera3D PlayerCamera3D;
    private Camera3D PlayerCamera3D2;

	public override void _Ready()
	{
		Head = GetNode<Node3D>("Nek/Head");
		Nek = GetNode<Node3D>("Nek");
        	StandingCollisionShape3D = GetNode<CollisionShape3D>("Standing_CollisionShape3D");
        	CrounchCollisionShape3D = GetNode<CollisionShape3D>("Crouch_CollisionShape3D");
		PlayerRayCast3D = GetNode<RayCast3D>("PlayerRayCast3D");
		//Both are null 
		PlayerCamera3D = GetNode<Camera3D>("%PlayerCamera3d");
        	PlayerCamera3D2 = GetNode<Camera3D>("Player/Nek/Head/PlayerCamera3d");

        	Input.MouseMode = Input.MouseModeEnum.Captured;
	}

I can’t understand why .
Thanks

try
PlayerCamera3D2 = GetNode<Camera3D>("Nek/Head/PlayerCamera3d");

1 Like

Worked , why its starting from Nek And Not Player ?

because the script is from Player, so route it from that
you can do it from /root/ if you want, that’s the absolute path

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.