invulnerability_timer.start
There are missing ()
at the end of this line.
onready var player = preload("res://player.gd").new()
This line creates a new instance of a player stored inside a variable, one for each zombie you have, which won't even be in the scene tree. Did you mean to get a reference to the existing player within the scene instead? You may want to consider get_node()
or some other mean of accessing the player. Since you use collisions, perhaps you could do this instead:
for i in get_slide_count():
var collision = get_slide_collision(i)
# This tests that the collider IS the player
if collision.collider.name == "player":
# So you can actually just call the function on it directly
collision.collider.damage(1)
If Godot tells you the damage()
function doesnt exist on the collider, try collider.get_parent()
instead (which should give you its physics body).
"Invalid call. Nonexistent function 'is_stopped' in base 'Nil'.
It means the invulnerability_timer
variable is null. You may check how you are initializing it. However, I assume that because of the previous problem I mentionned, those "player" instances never entered the tree so were never _ready
.