From c91e481cddb001474443d5268f4b397f1c546548 Mon Sep 17 00:00:00 2001 From: Charles Heckroth Date: Sun, 18 Aug 2024 12:02:46 +0900 Subject: [PATCH] Add projectile scaling workaround Adds a workaround that manually scales the children of the Projectile scene. This is due to a problem where the projectile root node scale does not propagate down to the sprite or collision shape within it. /~https://github.com/godotengine/godot/issues/5734 --- units/projectile.gd | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/units/projectile.gd b/units/projectile.gd index 54ea423..dba7b6d 100644 --- a/units/projectile.gd +++ b/units/projectile.gd @@ -10,7 +10,8 @@ func spawn(owner: Node, spawn_with_projectile_effects: Array[ProjectileEffect], projectile_effects = spawn_with_projectile_effects var local_transform = parent_transform for effect in projectile_effects: - add_child(effect.instantiate()) + add_child(effect) + effect.set_owner(self) effect.modify_creation(owner, projectile_effects, local_transform) # Spawn the default projectile # TODO:: Projectile spawn modification may want to prevent the default from spawning @@ -19,8 +20,19 @@ func spawn(owner: Node, spawn_with_projectile_effects: Array[ProjectileEffect], projectile_effects = projectile_effects transform = local_transform +func scale_projectile(new_scale: Vector2): + $Sprite2D.scale = new_scale + $CollisionShape2D.scale = new_scale + +func _ready(): + if scale != Vector2.ONE: + scale_projectile(scale) + func _physics_process(delta): var position_modifier = transform.x * SPEED * delta for effect in projectile_effects: position_modifier = effect.modify_physics(position_modifier) set_position(position + position_modifier) + +func _integrate_forces(delta): + scale = Vector2(100, 100)