![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | thestartingguy |
I’m trying to figure out how to make sure new instances(asteroids) spawn in front of my “player” when he is moving and the ones that are out of the view get deleted. because for now, each asteroid is spawning to slow behind the player. also how would you make them spin slowly when spawning, in different directions to look more like “realistic asteroids”, if the asteroids come from the bottom up it doesn’t bother me thats actually good to?
if this looks bad I barely know anything about codeing.
`extends Node2D
var pre_flyingobject= preload(“res://objects/flyingobject.tscn”)
var good_to_spawn=true
Called when the node enters the scene tree for the first time.
func _ready():
pass
func _process(delta):
pass
func _on_Area2D_body_entered(body):
if "flying" or "player" in body.name:
good_to_spawn=false
func _on_Timer_timeout():
if good_to_spawn==true:
var new_flyingobject=pre_flyingobject.instance()
get_parent().add_child(new_flyingobject)
new_flyingobject.position=position
queue_free()`