Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | SpaceyProt |
Hello! I’m trying to build a first game in Godot after a few years in GameMaker. So far I’m not sure about the node structure even though I’ve checked a number of tutorials. So far I have a Game node where on timer_timeout I spawn a spawner of my enemy. The reason I have a spawner of a spawner is because I first create node with animation of spawn and then on animation_finished I create the enemy (Jack) itself.
Here is relevant code:
Node Game
func _on_SpawnTimer_timeout():
var cellSize = 24
var xPos = stepify(rand_range(0, 240),cellSize) + cellSize/2
var yPos = stepify(rand_range(0, 426),cellSize) + cellSize/2
var spawn = SpawnerJack.instance()
add_child(spawn)
spawn.position = Vector2(xPos, yPos)
Node SpawnerJack
func _on_AnimatedSprite_animation_finished():
var spawn = Jack.instance()
add_child(spawn)
queue_free() in SpawnerJack won’t work as it will destroy the enemy as well so I’m not sure what else I can do… I would really appreciate a nudge in the correct direction.