This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+5 votes
extends "cannon_base.gd"

# Override
func catch(avatar):
    # How can I call the base function from cannon_base?
in Engine by (29,510 points)

1 Answer

+20 votes
Best answer

From http://docs.godotengine.org/en/latest/reference/gdscript.html#referencing-functions:

To call a function in a base class (i.e. one extend-ed in your current class), prepend . to the function name:
.basefunc(args)

So it's

func catch(avatar):
    .catch(avatar)
by (922 points)
selected by

Beware the note on that docs page:

Default functions like _init, and most notifications such as _enter_tree, _exit_tree, _process, _physics_process, etc. are called in all parent classes automatically. There is no need to call them explicitly when overloading them.

This information is all accurate for Godot 3, but in Godot 4 this information has changed.

From https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_basics.html:

To call a function in a super class (i.e. one extend-ed in your current class), use the super keyword:

super(args)

Additionally in Godot 4, default functions are no longer called in all parent classes automatically. You must call them explicitly when overloading them.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.