Lets say you want to have two GDscripts where the ChildScript.gd will call ParentScript.gd.
From there, you want the ChildScript.gd to call its parent function.
Create Class Inheritance
You first create inheritance in GDScript by calling “extends”.
1 2 3 4 |
extends "res://gdscript-filename.gd" #example extends "res://Parent.gd" |
Call Parent Function . Use dot “.” to call parent function
1 2 |
#function example, where child calls parent function .getText() |
Download Godot Project Example
In this example, when “Press Me” button is clicked. The label will change to “Parent Child” where “Parent” is return value from parent function while child is from child function.
You can download here the project example.