How can child class trigger parent class function/void/event?

I have theese two example scripts:

Child class:

using UnityEngine;
using System.Collections;

public class Health : MonoBehaviour
{
	public void Die()
	{
		Destroy(gameObject);
	}
}

Parent class:

using UnityEngine;
using System.Collections;

public class Player_Health : Health
{
	public void ShowDeadScreen()
	{
		FindObjectOfType<DeadScreen>().Show();
	}
}

And now I want to child class trigger “ShowDeadScreen()” in parent class, how?

Please help, thanks! :slight_smile:

A derived (child) class inherits all public methods from the base (parent) class. Just write the name of the method you want to execute.

You can make it an explicit call of the inherited method by using the “base” keyword, but it won’t make a differente unless you’ve overrided the method: base keyword - C# Reference | Microsoft Learn

Anyway, I think you are confused. In your example, “Health” is the base (parent) class and Player_Health is the derived (child) class. ShowDeadScreen is a method of the derived class only, the base class don’t have it and you can’t call that method on it.

Also, an object of type Player_Health is also of type Health, but it’s just one object, you can’t call a method “on the parent” class, you call a method on the object itself, and the method is either defined on that class or inherited from the base class.

What are you trying to do exactly?