When you detect the collision, you usually have a reference to the collider, that node, if has a "health" variable, the variable can be accessed with the dot notation like player.health
, then you can work with it and assign values (this will trigger setters and getters if you made any).
The best approach could be adding all the objects to a group that can take damage and add to all of them the function that calculates the damage.
It can be damage(value)
for direct damage, damage(bullet)
or similar if the damage depends on what does the damage (like using the speed of the bullet), or hurt(damage)
if your damage is a complex structure (like with effects or elements) or other, depends on the design.
The group is to abuse duck typing and avoid inheritance for interface-like stuff (you may need to damage siblings), it saves you from type-check too.
And check the shooter and platformer demos for some examples.