dimanche 14 novembre 2021

How can you get a random posistion around a known posistion in a 2d godot scene?

I am making an game that is like asteroids and I want to place an asteroid around the player but not always in the same place and not to far or close.

this is my current code(planet is another asteroid with a rigid body sprite and collision shape):

func create_asteroid():
   var planet_instance = asteroid.instance()
   asteroid_instance.position = self.position
   get_tree().get_root().call_deferred("add_child", asteroid_instance)



Aucun commentaire:

Enregistrer un commentaire