One of the Health Kits can't be picked up.

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

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

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)

$CollisionShape.disabled = true"die")

and this in my HP kit:

func __physics__process(delta):

var coll = raycast.get_collider()

if player == null:
if dead:

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 == "Player":
	print("colliding with HPKit")
	if <= 99: += 10

Any help? I just can not understand what am I doing wrong. Godot doesn’t show any error.

Solved it with the help of a good guy

NickIAm | 2021-03-02 02:52

:bust_in_silhouette: Reply From: NickIAm

Solved it by removing raycast from HPKit and making it Area object instead of a Kinematic body. Then added signal that was listening for entering bodies.

Enemy code that spawned kits changed too:

var zomb_pos = self.translation
zomb_pos.y = zomb_pos.y - 0.5
zomb_pos.x = zomb_pos.x + 0.5
var HPKit = HPkit.instance()