SInteractionActor class overview - whoisEllie/Project-Isolation GitHub Wiki

SInteractionActor

Overview

SinteractionActor is one of two parts that make up the generalised interaction system within isolation-game. This actor receives the interaction trace from the player character, using SInteractInterface. It receives a signal from SCharacter over the interface, and then delegates that interacted signal to a theoretically unlimited amount of interacted actors (this is not performed over an interface as we have direct references to these actors). The easiest way to visualise this is to imagine a light switch and a lightbulb. SInteractionActor functions as the switch, and passes a signal to as many of our lightbulbs (SInteractedActor) as we set up when it is pressed (interacted with). This class is designed to be operated through blueprint children.


Functions

  • virtual void Interact() override; - The override of the Interact function declared in SInteractInterface.

  • void OnInteraction(AActor* ImplementedActor); - A blueprint-implementable function that is called every time that a single actor is passed an interaction, used to extend functionality in blueprints for when an SInteractedActor is interacted with.

  • void InteractionCompleted(); - Another blueprint-implementable function that is called when all the given SInteractedActors have been interacted with. Used to extend functionality in blueprints.


Variables

  • TArray<ASInteractedActor*> InteractedActors; - An array of SInteractedActors which are set per instance in the editor. They define all the actors which are sent an Interacted() call.

  • FText PopupDescription; - The description shown on the players screen when looking at the actor. This is exposed to blueprints and can be modified there at runtime.

  • UStaticMeshComponent* MeshComp; - The default mesh implemented by this actor, used as RootComponent.


Uses

On its own, SInteractionActor is largely useless. It is when combined with SInteractedActor that it becomes a powerful system for handling interactions within your game. As you may have garnered from the amount of functions that exist to be implemented in blueprints, this is meant to act sort of like an API. It allows you to pass interactions from a single button to a web of actors, and can be expanded with custom logic in blueprints. Start by creating a child in blueprints, after which you can use the eye-dropper tool in the details panel to edit the instance of InteractedActors. In game when the child receives a line trace that implements SInteractInterface, it will delegate an Interacted() call to all the actors specified in the array.