+1 vote

Hey all,

I am currently working on a 2D space game and I would like to have an option to click on an NPC or other player to select them as my target (only 1 target at the time, of course). These targets, when selected by mouse click, will also show me their HP bar.

So the question is: how to make it work this way? I think that texture button without any texture is going to be OK for the target to be clickable/selected, but how to then get their own HP bar from their own HUD?

Thank you in advance! :-)

asked Dec 6, 2017 in Engine by IranosMorloy (59 points)

1 Answer

+4 votes
Best answer

CollisionObject2D (areas and all the bodies) have the "pickable" property, if that is enabled these will fire an input_event signal and also can use the _input_event callback (without a signal) to manage input events in their shape.

Check the "Area 2D Input Event" demo and the "3D Mouse Picking Test" (is 3D but similar to 2D).

answered Dec 7, 2017 by eons (7,786 points)
selected Dec 10, 2017 by IranosMorloy
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.