error CS0115: no suitable method found to override

ConsoleCompiler error · Scripting

error CS0115: 'X.Start()': no suitable method found to override

A method is marked override, but the base class has no virtual or abstract method with that name and signature. In Unity the usual case is override on Start, Update or another message method, which MonoBehaviour does not declare as virtual.

Read the Console line first

The message names the class and method marked override. Compare its name, parameters and return type with the method in the base class.

Common causes

  1. Overriding a Unity message on MonoBehaviour

    Unity finds Start, Update and the other messages by name; MonoBehaviour does not declare them, so there is nothing to override.

    Example
    C#
    public class Enemy : MonoBehaviour
    {
        protected override void Start() { } // CS0115
    }
  2. The base method is not virtual

    Your own base class declares void Start() without virtual or abstract, so derived classes cannot override it.

  3. The signature differs

    The name, parameter types or return type differ from the base method, for example OnTriggerEnter(Collider2D) against a base OnTriggerEnter(Collider), or a typo in the name.

The fix

Fix
C#
public class Enemy : MonoBehaviour
{
    protected virtual void Start()
    {
        // shared setup
    }
}

public class Boss : Enemy
{
    protected override void Start()
    {
        base.Start();
        // boss-only setup
    }
}

Stop it coming back

Remove override from Unity message methods on classes that inherit MonoBehaviour directly. When several components share setup, declare the method protected virtual in your base class and call base.Start() from the override.

Questions

Do I need base.Start()?
Only when the base class's Start does work the derived class also needs. Calling it is the usual choice; forgetting it is a common source of half-initialized objects.
Should Unity messages be public?
No. Unity calls them whatever their access level. Keep them private, or protected virtual when subclasses override them.
What about the 'hides inherited member' warning?
That is CS0114: a derived class declares a method with the same name as a virtual one without override. Add override if you meant to replace it, or new if you meant to hide it.

Scripts that avoid it

Related errors

Got a different error? Paste it into the error lookup.