How I make an object kill inmediately my KinematicBody2D?

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

I want to make spikes that when the player touch it he die and the Game Over comes to screen.

:bust_in_silhouette: Reply From: exuin

Use an Area2D. You’ll need one on the spikes and one on the player. Connect the on_area_entered signal of the player’s Area2D to the player and then kill the player if the area is a spike (you can use collision layers or groups for this).

I don’t understand. There’s any scipt or something?

Nilo | 2021-04-05 10:33

Something like this:

func on_player_area_entered(area):
    if area.is_in_group("spikes"):
        player.kill()

exuin | 2021-04-06 20:16

Thaaaaaaaaaaaaaaaaaank you. It works

Nilo | 2021-04-06 20:23