Invalid cast when using [Export]

Godot Version



I’m getting “true” printed in the console with the following setup; meaning that the CharacterBody3D was never referenced correctly.

I have a player.tscn with a PlayerMovement script on the player.

public partial class PlayerMovement : Node
    [[Export] private CharacterBody3D _body;

    public void ApplyVelocity(Vector3 direction, double delta)
        // Prints true
        GB.Print(_body == null);

This is the PlayerMovement node setup, clearly referencing the body

I also have a main.tscn with the mentioned player.tscn as subscene. This is the main player node with a Player.cs attached to it.

extra ‘[’?
[Export] private CharacterBody3D _body;