<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://www.wlabsocks.com/wiki/index.php?action=history&amp;feed=atom&amp;title=OnPlayerDeath</id>
	<title>OnPlayerDeath - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://www.wlabsocks.com/wiki/index.php?action=history&amp;feed=atom&amp;title=OnPlayerDeath"/>
	<link rel="alternate" type="text/html" href="http://www.wlabsocks.com/wiki/index.php?title=OnPlayerDeath&amp;action=history"/>
	<updated>2026-05-06T00:50:57Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.5</generator>
	<entry>
		<id>http://www.wlabsocks.com/wiki/index.php?title=OnPlayerDeath&amp;diff=781&amp;oldid=prev</id>
		<title>Tayfunwiki: Created page with &quot;== &lt;code&gt;onPlayerDeath&lt;/code&gt; Event in Actor Class ==  === Overview === The &lt;code&gt;onPlayerDeath&lt;/code&gt; event in the &lt;code&gt;Actor&lt;/code&gt; class is a critical feature designed to handle the death of the player-character within a game. This event plays a significant role in scenarios where the player's death impacts gameplay, narrative, or triggers specific in-game responses.  === Description ===  * Event Type: &lt;code&gt;Action&lt;/code&gt; * Functionality: This event triggers when the...&quot;</title>
		<link rel="alternate" type="text/html" href="http://www.wlabsocks.com/wiki/index.php?title=OnPlayerDeath&amp;diff=781&amp;oldid=prev"/>
		<updated>2023-12-24T19:47:55Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;== &amp;lt;code&amp;gt;onPlayerDeath&amp;lt;/code&amp;gt; Event in Actor Class ==  === Overview === The &amp;lt;code&amp;gt;onPlayerDeath&amp;lt;/code&amp;gt; event in the &amp;lt;code&amp;gt;Actor&amp;lt;/code&amp;gt; class is a critical feature designed to handle the death of the player-character within a game. This event plays a significant role in scenarios where the player&amp;#039;s death impacts gameplay, narrative, or triggers specific in-game responses.  === Description ===  * Event Type: &amp;lt;code&amp;gt;Action&amp;lt;/code&amp;gt; * Functionality: This event triggers when the...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== &amp;lt;code&amp;gt;onPlayerDeath&amp;lt;/code&amp;gt; Event in Actor Class ==&lt;br /&gt;
&lt;br /&gt;
=== Overview ===&lt;br /&gt;
The &amp;lt;code&amp;gt;onPlayerDeath&amp;lt;/code&amp;gt; event in the &amp;lt;code&amp;gt;Actor&amp;lt;/code&amp;gt; class is a critical feature designed to handle the death of the player-character within a game. This event plays a significant role in scenarios where the player's death impacts gameplay, narrative, or triggers specific in-game responses.&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
&lt;br /&gt;
* Event Type: &amp;lt;code&amp;gt;Action&amp;lt;/code&amp;gt;&lt;br /&gt;
* Functionality: This event triggers when the player-character, represented by the &amp;lt;code&amp;gt;Actor&amp;lt;/code&amp;gt; class, dies. It provides a mechanism for implementing reactions or logic specific to this event, such as game-over sequences, narrative progression, or changes in game state.&lt;br /&gt;
&lt;br /&gt;
=== Usage ===&lt;br /&gt;
The event is utilized to trigger various actions upon the player-character's death, including updating the game state, altering narrative elements, or executing specific gameplay mechanics.&lt;br /&gt;
&lt;br /&gt;
=== Subscribing to the Event ===&lt;br /&gt;
Subscribe to the &amp;lt;code&amp;gt;onPlayerDeath&amp;lt;/code&amp;gt; event within a MonoBehaviour script to implement custom responses to the player-character's death. Unsubscribing from the event is crucial to prevent memory leaks and unwanted behavior, particularly when the scene changes or the actor instance is destroyed.&lt;br /&gt;
&lt;br /&gt;
=== Example of Usage ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c#&amp;quot;&amp;gt;&lt;br /&gt;
public class ActorDeathHandler : MonoBehaviour {&lt;br /&gt;
    public Actor actor;&lt;br /&gt;
&lt;br /&gt;
    void Start() {&lt;br /&gt;
        if (actor != null) {&lt;br /&gt;
            actor.onPlayerDeath += OnPlayerDeath;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    private void OnPlayerDeath() {&lt;br /&gt;
        Debug.Log($&amp;quot;{actor.FullName} has died.&amp;quot;);&lt;br /&gt;
        // Additional logic to handle the actor's death&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    void OnDestroy() {&lt;br /&gt;
        if (actor != null) {&lt;br /&gt;
            actor.onPlayerDeath -= OnPlayerDeath;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;In this Unity script, the &amp;lt;code&amp;gt;ActorDeathHandler&amp;lt;/code&amp;gt; is attached to a GameObject and subscribes to the &amp;lt;code&amp;gt;onPlayerDeath&amp;lt;/code&amp;gt; event of an &amp;lt;code&amp;gt;Actor&amp;lt;/code&amp;gt;. When the player-character dies, the &amp;lt;code&amp;gt;OnPlayerDeath&amp;lt;/code&amp;gt; method logs the death, and additional actions can be implemented as needed.&lt;br /&gt;
&lt;br /&gt;
=== Remarks ===&lt;br /&gt;
&lt;br /&gt;
* The &amp;lt;code&amp;gt;onPlayerDeath&amp;lt;/code&amp;gt; event is essential in creating dynamic and engaging gameplay experiences, particularly in titles where the player's survival is a key element.&lt;br /&gt;
* Handling this event effectively can significantly contribute to the narrative and emotional depth of the game, providing a poignant response to the player-character's demise.&lt;br /&gt;
* This event is relevant across various genres, especially in adventure, survival, role-playing, and action games, where the life and death of the player-character are central to the game's progression.&lt;/div&gt;</summary>
		<author><name>Tayfunwiki</name></author>
	</entry>
</feed>