I got an issue where inheritance is not working.
I get this error.
res://addons/water/scripts/script_water_water_body.gd:23 - Invalid call. Nonexistent function 'run_water_shape' in base 'Node (WaterWaterShapeGerstnerWavesGeneratedMinMax)'.

I restarted the editor multiple times and even remade the files. Also toggled off the plugin and toggled it back on.

Here is parent class.

extends Node
class_name WaterWaterShape

func _ready(): pass
func _process(delta): pass
func run_water_shape(time_in:float, resolution_in:int, position_offset_in:Vector2)->void:
	pass;

Here is child class.

class_name WaterWaterShapeGerstnerWavesGeneratedMinMax 
extends WaterWaterShape

func _ready(): pass
func _process(delta): pass
func run_water_shape(time_in:float, resolution_in:int, position_offset_in:Vector2)->void:
	resolution = resolution_in;
	time = time_in;
	position_offset = position_offset_in;
	_init_compute_shader();
	_update_compute_shader_uniforms();
	_run_compute_shader();
	_read_compute_shader_results();
	_refresh_resources();

Here is how I am using child class.

@tool
extends Node3D
class_name WaterWaterBody

# Resolution
const RESOLUTION_MAX = 1024;
const RESOLUTION_MIN = 8;
var resolution = 1024;

var time;

func _ready():
	time = 10;

func _process(delta):
	
	# Progress time
	time += delta;
	
	# Run water shapes
	for water_shape in get_water_shapes():
		water_shape.run_water_shape(time, resolution,Vector2(0,0));
		
func get_water_shapes() -> Array:
	
	var children = get_children();
	var water_shapes_array = [];
	for child in children:
		if child is WaterWaterShape:
			water_shapes_array.append(child);
	return water_shapes_array;
  • Toxe replied to this.
  • Your issue doesn't have to do with inheritance. Your problem is a tool script trying to call functions on two non-tool scripts. If a script isn't a tool, Godot doesn't bother having its functions available in-editor.

    If your intent is to call run_water_shape in the editor all the time, not just when the game is running, then add @tool to the top of your WaterWaterShape and derived classes.

    If you weren't intending to call it in the editor, then remove @tool from that third script or add

    if Engine.is_editor_hint():
    	return

    to the top of _process.

    wayfarerGameDev Does it work if you just create an object of class WaterWaterShapeGerstnerWavesGeneratedMinMax and then try to call its run_water_shape() method?

    Also is this Godot 3 or 4?

      Your issue doesn't have to do with inheritance. Your problem is a tool script trying to call functions on two non-tool scripts. If a script isn't a tool, Godot doesn't bother having its functions available in-editor.

      If your intent is to call run_water_shape in the editor all the time, not just when the game is running, then add @tool to the top of your WaterWaterShape and derived classes.

      If you weren't intending to call it in the editor, then remove @tool from that third script or add

      if Engine.is_editor_hint():
      	return

      to the top of _process.