Having obstacles and collisions are cool, but we need a way to determine if anything has happened if they collide.
Let’s add a health component.
Select the ship and click on Add Component. Type Health System Attribute and select it to add the component to the ship.
Next, add a UserInterface Prefab to the Scene. Hint it’s located in the Assets.
Run it. Did it work? Dang!
We need to connect the two objects somehow together. There are three more things we need to do. First, select the collision object.
Then, click Add Component and type Modify Health.
Next, in the Inspector for the collision object, look at the top for the tag and change it from unnamed to enemy.
Select the Ship and change its tag from unnamed to player.
Now, run the project and see what happens. Yeah! The health went down, but if you hit it twice, the health goes down again.
Go back to the collision object and look for the Modify Health and check the Destroy when Activated.
Rerun it and see what happens. Did it work better? Great!
Now, let’s do some hands-on work.