kippie
January 9, 2025, 6:24pm
1
i’m making a remake of don’t touch the spikes! in godot to learn the engine.
when you touch a wall in my game, i want to send a signal from the player to the spikes to remove themselves, the spikes and player are in different scenes.
how to do this?
wchc
January 9, 2025, 7:34pm
2
Ideally, you’d want your Spikes to be an Area3D
that can detect the Player and remove themselves.
See my little demo:
This is the scene structure
This is player.gd
script
class_name Player
extends CharacterBody2D
func _physics_process(delta: float) -> void:
velocity = Vector2.RIGHT * 200.0
move_and_slide()
spikes.gd
class_name Spikes
extends Area2D
func _ready() -> void:
body_entered.connect(_on_body_entered)
func _on_body_entered(body: Node) -> void:
if body is Player:
queue_free()
1 Like
kippie
January 10, 2025, 1:55pm
3
it worked, thanks! i was thinking of sending a signal to the spikes when you touch a wall to delete them, but i think your solution is better.