Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Guiguis_Galdis |
I am very new to Godot and my first project is a simple mario-like platform with enemies that (should) die if you jump on them, but it’s not working
extends KinematicBody2D
onready var alive = get_tree().get_root().get_node("World/Player").alive
onready var spawn_point = get_tree().get_root().get_node("World/Player").spawn_point
func _ready():
$area_enemy.connect("body_entered", self, "body_entered")
$hitbox.connect("body_entered", self,"body_entered")
func on_area_enemy_body_entered(body):
if body.name == "Player":
alive = false
print(alive)
body.position = spawn_point
alive = true
And this is the code for when the player jumps on the enemy:
func on_hitbox_entered(body):
if body.name == "Player":
queue_free()
I am very much a noob and any kind of help is appreciated