Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Drai3Seltor |
Hi, I am new to coding, but I am learning quickly and I am finishing my first 2D rpg level and as the final boss I wanted to put someone that would have spawn enemy at random location around him when hit.
It is going all good but during the script I put something like this:
var rand = 0
var randx = 0
var randy = 0
func _percentage():
rand = rand_range(0,100)
if rand > 90:
randx = rand_range(-200, 200)
randy = rand_range(-200, 200)
var enemyscene = load("res://Enemy.tscn")
var enemy = enemyscene.instance()
enemy.position.x = randx
enemy.position.y = randy
add_child(enemy)
But then the enemy being child node of the boss move with him and so they are pretty useless.
How can I do to spawn an indipendent node?
Thank you very much