I try to make a game and I have a problem...
I have the scene of an enemy and connected his attackArea with his kinematicbody. In an other scene ( Player ) I have the variable health.
And when the body entered then I try to subtract the variable health by 10
How is this possible???
I tried with
get_node("/root/Player) but it didnt work...
For anybody who needs it, here is my enemy scrpt:
export var health = 50
export var speed = 100.0
export var attack_load = 0.4
var velocity = Vector2()
var player = null
var can_attack = true
velocity = Vector2()
velocity = position.direction_to(player.position) * speed
velocity = move_and_slide(velocity)
if health <= 0:
player = body
player = null
if can_attack == true:
get_node("/root/Player")health -= 5
can_attack = false
can_attack = true