Beginner help GetCollider() with C#

I am new to godot so sorry if this is basic. The Issue is that the GetCollider() method returns GodotObject while I want to use the methods in the Script attached to the Collider (GetPrompt() ). Casting to the Script Type Doesn’t seem to work. For clarification I am trying to run the method GetPrompt() in the interactable object through the RayCast Script .
I Have a simple interactable Node with the Following Script Attached:

public partial class InteractableCollider : CollisionShape3D
{
[Export]
StringName prompt = “Iteracting”;

public StringName GetPrompt() 
{
    return $"{prompt}";     
}

}
Then My character has another Script Attached to the RayCast:

public partial class InteractRay : RayCast3D
{
public override void _Ready()
{
}

public override void _PhysicsProcess(double delta)
{
	ForceRaycastUpdate();
	if (IsColliding()) 
	{
		var detected = GetCollider();
		if (detected is InteractableCollider) {
            GD.Print(detected.GetPrompt());
        }
		
	}
}

}

Thanks.

I simply Needed to Use the detected.Call(funcName) method which I didn’t know existed.

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