First make the health system without regards to how it looks like.
1) Player and harmful objects need colliders. Decide if you go with 2D or 3D physics. 2D is definitely easier, but requires a specific setup and not all Unity features are fully available, most noticeable the lack of navmesh ( thought there are alternatives). Very important: this determines the components and the action you’ll use. All the 2D physics elements and actions have 2D in the name. It will not work when you mix.
2) Next, you decide on triggers or colliders. It’s both the same collider component in different shapes. You switch this to trigger by checkbox in the collider options. You then need to use specific trigger actions instead of collision actions. In a nutshell, collisions use forces that push the objects around. If you don’t want that or don’t use that, set them to triggers (it seems to be that triggers want a rigidbody on the other object to get triggered).
3) It’s most versatile to put the damage system on its own game object and as a child of the holder, but if you want to keep it simple, you can just use the holder object (i.e. the player). It must be on the same object that has the collider/trigger (at least in a simple version).
4) The harmful object likewise need a collider/trigger. Again, determine if you want collision or just detect if something touches the collider/trigger object.
5) Set the layers for the objects with colliders. It’s a bit confusing at first, but of course will start to make sense with practice. Open project settings and under your physics, normal or 2D, find the collision matrix. By default everything collides with most stuff. But here you need to set a checkmark where the two layers of damage-dealer and receiver meet.
6) Your system seems super easy, so you can theoretically make the player damage itself on collision. To do this, and say you went with triggers 2D, you add the actions on “trigger enter 2D” into the fsm on the player object where the trigger sits. This basically waits until it collides with something. If so, int substract (or int add -1) from hearts int variable of three. After that, make a state that int compares against 0, and if zero, restart level action. Super cool trick: instead of the on trigger enter 2D action, you can use the system global event of that name. This leads to a separate state, and runs from there (and not from start).
7) For the visual UI: if it is really simple, you can use Djaydino’s idea with the int switches. I would simply make one heart UI image, duplicate and arrange on the canvas, and in each int switch states, use the activate game object action to show / hide the correct amount. If the player is a prefab, each UI heart needs its own tag, so you can find it with get child or find child (the one to look for tags).
I probably forgot a thing or two, but it should cover most of it.