Can't understand what is happening. One of the kits can't be picked up. Tried to look up through web but couldn't find any solution. If one is spawned it can't be picked. If spawned few the first one that player has collided with.
I have this in my enemy script:
func kill():
dead = true
random.randomize()
if random.randi_range(1,50) == 42:
var zomb_pos = self.translation
zomb_pos.y = zomb_pos.y - 0.5
var HPKit = HPkit.instance()
get_tree().call_group("powerups", "set_player", self)
get_parent().add_child(HPKit)
HPKit.translate(zomb_pos)
$CollisionShape.disabled = true
anim_player.play("die")
get_node("Sounds/Death").play()
and this in my HP kit:
func __physics__process(delta):
var coll = raycast.get_collider()
if player == null:
return
if dead:
return
var vec_to_plr = player.translation - translation
vec_to_plr = vec_to_plr.normalized()
raycast.cast_to = vec_to_plr * 1.1
if raycast.is_colliding() and coll != null and coll.name == "Player":
print("colliding with HPKit")
if coll.health <= 99:
coll.health += 10
kill()
Any help? I just can not understand what am I doing wrong. Godot doesn't show any error.