diff options
Diffstat (limited to 'Scenes/Entities/Bombs/Bomb.gd')
-rw-r--r-- | Scenes/Entities/Bombs/Bomb.gd | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/Scenes/Entities/Bombs/Bomb.gd b/Scenes/Entities/Bombs/Bomb.gd index 4256fc5..97fbf4f 100644 --- a/Scenes/Entities/Bombs/Bomb.gd +++ b/Scenes/Entities/Bombs/Bomb.gd @@ -16,7 +16,7 @@ enum COMPONENT_TYPE { } -var Explosion = preload("res://Scenes/Entities/Bombs/Explosion.tscn") +var ExplosionScene = preload("res://Scenes/Entities/Bombs/Explosion.tscn") var power: int = 2 var components: Array[COMPONENT_TYPE] = [] @@ -60,17 +60,21 @@ func explode(): var direction = directions[j] for i in range(self.get_power()): + var from = Utilities.from_grid_to_position( + Utilities.from_position_to_grid(self.global_position) + (direction * i) + ) var to = Utilities.from_grid_to_position( Utilities.from_position_to_grid(self.global_position) + (direction * (i + 1)) ) - var query = PhysicsPointQueryParameters2D.new() - query.set_position(to) + var query = PhysicsRayQueryParameters2D.new() + query.set_from(from) + query.set_to(to) query.set_collision_mask(explosion.collision_mask) - var explosion_intersection = get_world_2d().direct_space_state.intersect_point(query) + var explosion_intersection = get_world_2d().direct_space_state.intersect_ray(query) if explosion_intersection: - var collider = explosion_intersection[0].collider + var collider = explosion_intersection.collider # call collision function and get collision type var collision_type @@ -120,7 +124,7 @@ func get_power(): func spawn_explosion(spawn_position: Vector2): - var explosion = Explosion.instantiate() + var explosion = ExplosionScene.instantiate() explosion.position = spawn_position get_tree().get_current_scene().add_child(explosion) |