diff --git a/addons/block_code/simple_spawner/simple_spawner.gd b/addons/block_code/simple_spawner/simple_spawner.gd index 1bb196e3..8e30b57b 100644 --- a/addons/block_code/simple_spawner/simple_spawner.gd +++ b/addons/block_code/simple_spawner/simple_spawner.gd @@ -34,6 +34,12 @@ enum LimitBehavior { REPLACE, NO_SPAWN } ## - No Spawn: No spawn happens until any spawned scene is removed by other means. @export var limit_behavior: LimitBehavior +## Whether the scene being spawned is rotated according to the SimpleSpawner node: +## - If the spawned scene is a RigidBody2D, the linear velocity and constant forces +## are rotated according to the SimpleSpawner node global rotation. +## - If the spawned scene is a Node2D, the rotation is copied from the SimpleSpawner node. +@export var rotate_with_spawner: bool = true + var _timer: Timer var _spawned_scenes: Array[Node] @@ -99,6 +105,12 @@ func spawn_once(): var scene: PackedScene = scenes.pick_random() var spawned = scene.instantiate() _spawned_scenes.push_back(spawned) + if rotate_with_spawner: + if spawned is RigidBody2D: + spawned.linear_velocity = spawned.linear_velocity.rotated(global_rotation) + spawned.constant_force = spawned.constant_force.rotated(global_rotation) + elif spawned is Node2D: + spawned.rotate(global_rotation) match spawn_parent: SpawnParent.THIS: add_child(spawned)