- Home /
I need help with Health System
Hey i have this script that makes damage(to our player) every time a falling enemy falls and collide to our player, but i also wanna make damage to our player if the enemy falls (collide) with the floor. How can i do it?
Answer by Caeser_21 · Mar 05 at 04:31 AM
You can make the floor have a tag (called "Floor"), then just use that tag like :
if (collisiongameObject.tag == "Floor")
{
health Playerhealth = GameObject.FindGameObjectWithTag("Player").GetComponent<health>();
Playerhealth.TakeDamage(Enemydamage);
}
EDIT : All the issues in the script are fixed
There's a small error you should make the "If" to "if". I have changed the script
I think health script is on the player, not under the floor and the issue is playerHealth is null
Your answer
Follow this Question
Related Questions
Trouble with communication between scripts 2 Answers
How to make a player health script and enemy damage script that is easily changed? 2 Answers
Regenerate health over time 2 Answers
Die on collision doesnt work 2 Answers
Unity Health Math Problem 1 Answer