Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Rhombazoid |
I am working on a tactical RPG game, and I thought it would be a good idea to add a health bar to the selected unit and all of the units affected by an attack. So far, it’s working great. I just need a way to remove the health bars from units that are no longer involved in combat. I thought, Easy, I’ll just use a group call to hide all the health bars when we select a new one.
func attempt_unit_selection(grid_pos: Vector2) -> void:
active_unit = null
for unit in unit_positions:
if unit_positions[unit] == grid_pos:
active_unit = unit
get_tree().call_group('units','hide_health_bar')
$UnitInfo.hide()
if active_unit != null:
$UnitInfo.display(active_unit)
active_unit.show_health_bar()
Except, it looks like the get_tree().call_group() is occuring after the final line in this code. Any ideas?
Enemy1 showing health!
Enemy3 hiding health!
Enemy1 hiding health!
Enemy2 hiding health!
It’s worth noting that the $UnitInfo calls that show more detailed information about the units is showing and hiding as expected.