2D Water tutorail 4.0

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By primevolcano

I have been following this tutorail [https://www.youtube.com/watch?v=RXIRkou021U&t=208s]
and at about 22:33 they link up a signal via Object.connect(“splash”, self, "splash)
this doesn’t work
if anyone could go throught the tutoial and help please do
the code for both is followed

Water Body

extends Node2D

@export var k = 0.015
@export var d = 0.03
@export var spread = 0.0002

var springs =
var passes = 8

@export var distance_between_springs = 32
@export var spring_number = 6

var water_legth = distance_between_springs * spring_number

@onready var water_spring = preload(“res://src/Water/water_spring.tscn”)
@onready var water_border = $water_border
@export var border_thickness = 1.1
@export var depth = 1000
var target_height = global_position.y
var bottom = target_height + depth

@onready var water_polygon = $water_polygon

func _ready():
water_border.width = border_thickness

for i in range(spring_number):
	var x_position = distance_between_springs * i
	var w = water_spring.instantiate()
	
	add_child(w)
	springs.append(w)
	w.initialise(x_position, i)
	w.set_collision_width(distance_between_springs)
	w.connect("splash",self,"splash")
splash(2,5)

func _process(delta):
pass

func _physics_process(delta):
for i in springs:
i.water_update(k,d)

var left_deltas = []
var right_deltas = []

for i in range(springs.size()):
	left_deltas.append(0)
	right_deltas.append(0)
	
for j in range(passes):
	for i in range(springs.size()):
		if i > 0:
			left_deltas[i] = spread * (springs[i].height - springs[i-1].height)
			springs[i-1].velocity += left_deltas[i]
		if i < springs.size() -1:
			right_deltas[i] = spread * (springs[i].height - springs[i+1].height)
			springs[i+1].velocity += right_deltas[i]
new_border()
draw_water_body()

func splash(index,speed):
if index >= 0 and index < springs.size():
springs[index].velocity += speed

func draw_water_body():

var curve = water_border.curve
var points = Array(curve.get_baked_points())

var water_polygon_points = points

var first_index = 0
var last_index = water_polygon_points.size()-1


water_polygon_points.append(Vector2(water_polygon_points[last_index].x, bottom))
water_polygon_points.append(Vector2(water_polygon_points[first_index].x, bottom))

water_polygon_points = PackedVector2Array(water_polygon_points)

water_polygon.set_polygon(water_polygon_points)

func new_border():
var curve = Curve2D.new().duplicate()

var surface_points = []
for i in range(springs.size()):
	surface_points.append(springs[i].position)

for i in range(surface_points.size()):
	curve.add_point(surface_points[i])

water_border.curve = curve
water_border.smooth(true)
water_border.queue_redraw()

water spring

extends Node2D

var velocity = 0
var force = 0
var height = 0
var target_height = 0
var index = 0
var motion_factor = 0.02

signal splash

@onready var collision_shape_2d = $Area2D/CollisionShape2D

func water_update(spring_constant, dampening):
height = position.y

var x = height - target_height
var loss = -dampening * velocity

force = - spring_constant * x + loss

velocity += force

position.y += velocity

func initialise(x_position,id):
height = position.y
target_height = position.y
velocity = 0
position.x = x_position
index = id

func set_collision_width(value):

var extents = collision_shape_2d.shape.size
var new_extents = Vector2(value/2,extents.y)
collision_shape_2d.shape.size = new_extents

func _on_area_2d_body_entered(body):
var speed = body.velocity.y * motion_factor
emit_signal(“splash”,index,speed)

:bust_in_silhouette: Reply From: primevolcano

SOLVED
I just had to do

w.connect("splash",splash)