My first goal is for players to not be able to walk through enemies. Second, I want the enemy's name and HP bar to appear when the enemy is clicked on. I can only achieve one goal but not both. I'm using Godot v3.0.6 & GDScript.
The relevant part of the tree~ Name (Node Type) - description:
Main (Node) - the root
--OtherHP (TextureProgress) - the targeted enemy or ally's HP bar
-Enemy (Node) - all enemies will be children of this node
--BadCat (KinematicBody2D) - my test enemy
--Sprite (Sprite) - my placeholder sprite, static for now
---EnemyName (Label) - his name appears over his head
--CollisionPolygon2D (CollisionPolygon2D) - drawn over the sprite's feet
~ Alternative Enemy Tree ~
--BadCat (Area2D) - change kinematicbody2D to area2D + fix references in scripts
On BadCat, the
input_event( Object viewport, Object event, int shape_idx) signal is connected to
../../UI :: _on_BadCat_input_event()
func _on_BadCat_input_event(viewport, event, shape_idx):
If I use the KinematicBody2D version, my player sprite cannot walk through the enemy. However, mousing over and clicking does nothing. The HP bar and name remain hidden.
If I use the Area2D version, mousing over prints lots of "test" and clicking causes the HP bar and name to show. However my player sprite phases through the enemy like it's a ghost.
How can I have it all: corporeal and clickable enemies?