epicsninja Further testing leads me to believe I am half correct. I have created the following custom node, and childed it to my Player Node, which is a
Rigidbody3D with a
PlayerController script attached.
public partial class GizmoDrawer : Node
public override void _EnterTree()
parent = GetParent();
public override void _Process(double delta)
DebugDraw2D.SetText("Parent is Null: " + (parent == null));
DebugDraw2D.SetText("Parent Script Path:" + parent.GetScript().As<CSharpScript>().ResourcePath);
DebugDraw2D.SetText("Has method: " + ((PlayerController)parent).HasMethod(PlayerController.MethodName.TestString));
DebugDraw2D.SetText("Result:" + ((PlayerController)parent).Call(PlayerController.MethodName.TestString).ToString());
While in the editor, this throws an error and outputs
System.InvalidCastException: Unable to cast object of type 'Godot.RigidBody3D' to type 'PlayerController'. to the console. However, if the script is marked as
[Tool] or when run in-build, it works fine, and as intended.
I can't tell if this is a bug, or intentional behaviour, but it seems like in-editor I am only allowed to access the base node type, while in-game I am able to access the script attached to the node.