system
1
|
|
|
 |
Attention |
Topic was automatically imported from the old Question2Answer platform. |
 |
Asked By |
GAMESTER_VIRUS |
here is the code:
randomize()
var damage = rand_range(10.0, 30.0)
get_node("/root/World/Enemy").health -= damage
if get_node("/root/World/Enemy").health == 0.0:
collider.queue_free()
system
2
|
|
|
 |
Reply From: |
Spiky_Potato |
Well, something you could try is setting the node as a variable. Something like this:
onready var Enemy = get_node("/root/World/Enemy")
Then all you’d have to do is reference the variable and the inner variable as an extension:
randomize()
var damage = rand_range(10, 30)
Enemy.health -= damage
if Enemy.health == 0
collider.queue_free()
This is at least what I’d try. Hopefully it helps.