Beginner-friendly, Unity 2D tutorial showing how to set up a basic health system for your player. This video shows how to link your player's health to enemies, so they can deal damage.
📖 CHAPTERS 📖
0:00 - Demo and Project Setup
0:54 - Writing the Player Health Script
2:24 - Writing the Enemy Damage Script
6:04 - Setting up Enemy Damage in Unity
6:37 - Testing the Setup and Outro
💡 IF ENEMY IS MULT-HITTING THE PLAYER 💡
A common problem for some users is that the enemy multi-hits the player, sometimes even destroying him/her right away. Most often, this is because the enemy detects multiple collisions. As set up, the enemy will deal damage for EVERY collider on the player (including child objects of the player). If you want to make sure that only one collision occurs, edit your script to read:
if(collision.collider.tag == "Player").
Adding the "collider" key word, will cause the damage to only be dealt once per attack, instead of once per collider encountered.
🛑 MUSIC 🛑
🔊Running Out - Patrick Patrikios
Support by RFM - NCM: https://bit.ly/2xGHypM
Watch video Player Health System #1: Taking Damage (Unity Tutorial) online without registration, duration hours minute second in high quality. This video was added by user Night Run Studio 11 April 2022, don't forget to share it with your friends and acquaintances, it has been viewed on our site 29,806 once and liked it 657 people.