OnRuntimeActorCreated

From Intrigues Wiki

onRuntimeActorCreated Event in IM Class

Overview

The onRuntimeActorCreated event in the IM (Intrigue Manager) class is triggered when a runtime actor is created within the game world.

Description

  • Event Type: Action<Actor, GameObject>
  • Functionality:
    • This event is activated when a new actor is instantiated at runtime.
    • It passes two parameters upon invocation:
      • An Actor object representing the newly created actor.
      • A GameObject associated with the actor, typically representing its in-game entity or avatar.

Usage

The onRuntimeActorCreated event is crucial for handling the creation of new actors in the game. It enables developers to execute specific actions or scripts when a new actor enters the game world, such as initializing actor-specific behaviors, updating game states, or integrating the actor into existing game systems.

Example of Usage

public class ActorCreationHandler : MonoBehaviour {
    void OnEnable() {
        IM.onRuntimeActorCreated += HandleNewActor;
    }

    void OnDisable() {
        IM.onRuntimeActorCreated -= HandleNewActor;
    }

    private void HandleNewActor(Actor actor, GameObject actorGameObject) {
        Debug.Log($"New runtime actor created: {actor.Name}");
        // Additional logic to process the new actor
        // This could include adding custom components, setting up interactions, or integrating the actor into game narratives
    }
}

Description:

  • HandleNewActor: Subscribed to the onRuntimeActorCreated event, this method is called when a new runtime actor is created. It processes the actor and its associated GameObject, allowing for responses such as customization, integration into gameplay, or other actor-specific setup.

Remarks

  • The onRuntimeActorCreated event is particularly important in games that dynamically generate characters or NPCs, allowing for seamless integration of these actors into the game world.
  • Proper handling of this event contributes to a dynamic and evolving game environment, where new actors can enhance gameplay, narrative, or player interaction.
  • It's especially relevant in role-playing games, simulation games, or any genre that involves dynamic character creation and management.