fix spawning

This commit is contained in:
2024-07-03 14:41:24 +02:00
parent dbfff61052
commit 94e51d3009
8 changed files with 69 additions and 30 deletions

View File

@@ -1,6 +1,8 @@
extends KinematicBody2D
onready var immunity = 5
onready var immunity = 50
onready var tilesmap = $"/root/World/tilemap"
onready var rootnode = get_node("/root/World")
const MOVEMENT_VECTORS = [
Vector2.UP,
@@ -10,6 +12,9 @@ const MOVEMENT_VECTORS = [
]
func _physics_process(_delta):
if position != null:
if tilesmap.get_cellv(tilesmap.world_to_map(position)) != 0:
queue_free()
if immunity > 0:
immunity = immunity - 1
var movement = MOVEMENT_VECTORS[randi() % 4]
@@ -27,6 +32,6 @@ func _on_Hitbox_area_entered(_area):
var ooze = load("res://NPCs/ooze.tscn")
var instance = ooze.instance()
instance.position = position
get_parent().add_child(instance)
rootnode.add_child(instance)
queue_free()