How to make a spring block

Godot Version

4.2.2

Question

I’m making a 2D Platformer and I was wondering how I would make a spring block that when touched makes the player bounce? I already know how to make the collisions, and the spring makes a sound when touched, but I’m not sure how to send a signal to the player node and make it change velocity. Any help is appreciated, thank you. :slight_smile:

An Area2D could connect to it’s own body_entered signal, then check against the colliding body and if it is a player, apply the velocity and play the sound

extends Area2D

@export var up_force: float = 600

func _on_body_entered(body: Node2D) -> void:
	if body is CharacterBody2D:
		body.velocity.y += up_force
		$AudioStreamPlayer.play()
1 Like