1

In Godot, I get the error 'no suitable method found to override' for the default _Ready() function.

using Godot;
using System;

public class Box
{
    public enum BoxType
    {
        //HURT_BOX,
        //BLOCK_BOX
    }

    public bool Enabled { get; set; }
    public int Damage { get; set; }
    public Keyframe[] Keyframes { get; set; }

    private MeshInstance3D _mesh;
    private Fighter Fighter;

    // Called when the node enters the scene tree for the first time.

    public override void _Ready() {}

Does anyone know why this error is showing up and how I can fix it?

I tested removing the line of code by commenting it out but the error still appears.

2
  • 1
    Does Box need to inherit from a Godot class, like Node3D? Commented Jul 23 at 21:25
  • your class needs to inherit from Node (or Node3D / Node2D ) . public class Box : Node3D Commented Jul 23 at 21:25

1 Answer 1

2

The override are applicable for the base Node class (and all its inherited classes, like Node2D or Node3D). Any new class you create that should be a n object in the Godot system should inherit at least from Node.

You probably want to inherit from Node3D given that you have a mesh instance... but ultimately you only know if it is only from Node - depends on if you want your Box objects to have positions / transforms in 3D space or not.

public partial class Box : Node3D  // Here : inheritance from Node3D
{
    // ...

    // Now there is a _Ready method to override:
    public override void _Ready() {}

}

Also note the partial . I don't have a Godot ready to test it, but that's shown like this in the documentation, it may be necessary as well.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.