Interaction System
UE5 Quest System Version: 2.0How the Interaction System Works ...
The keybinding is defined by IA_Quest_Interact in the IMC_QuestSystem. This enhanced input action is initiated in the UI_QuestSystem_HUD, and when triggered it will call the Interact function on the AC_QuestSystem_PlayerController component. This function has an input to confirm performing the interaction at this point. If you set this to false the interaction system will just check to see if an interaction is possible without actually interacting. The return from this function is true if an interaction is performed or possible (if the input to try to interact is disabled).
This function runs on the client and will check to see if an InteractActor is set. Our InteractActor reference is set (from our AC_QuestSystem_Actor's overlapHelper function) when the player overlaps a Quest Actor with a valid interactable action, like showing a quest window or completing an interact objective.
When an attempt to interact is intended, and is possible, the server is notified to perform the interaction. This is handled in the interactHandlerServer function found in the AC_QuestSystem_PlayerController.
At this point the system will attempt to get the AC_QuestSystem_Actor component on our valid InteractActor reference. If it is found it will call the QuestInteractable? function on this component, which in turn runs the CheckPlayerInteract function on this component.
This function will verify that the player can interact with the actor, and will perform the interaction (if requested), which at this point would tell the AC_QuestSystem_PlayerController to open the quest window, or tell the AC_QuestSystem_PlayerState component to complete the objective when called for the Interact Objective.
What controls the Interaction Distance?
The size of the sphere overlap added to actors by our actor component is what controls the distance. By default the radius of this sphere is 150, you can override this value for your actor with the Quest Actors Option BPI. When your player moves out of the sphere the controller will detect this and unset the actor.
When you are in range of an actor a ping is performed to make sure you stay near it (and it stays near you). The functionality for this can be found in the checkInteractActor function in the AC_QuestSystem_PlayerController. This method is used in the event that the player or actor are teleported or the end overlap is not triggered for some reason, often occurring if the sphere or actor is destroyed or when a player tries to exploit.
Quest Windows will also attempt to auto close when the interact actor is unset. You can disable CloseQuestWindowOnMaxDistance inside UI_QuestSystem_HUD to stop the quest window from closing.
Changing to Line Trace
As you might have figured out by this point the default implementation uses overlaps to help drive the interaction event. This is the most common use case, however a good amount of you may still want to change this to a line trace instead. To help you get started I've provided a simple example of a line trace inside the BP_QuestDemoWorldPlayerCharacter in the Demo/ folder. See the instructions on the begin play of the event graph for instructions on how to activate it.
You will also want to disable the overlap events for anything related to interactions, you can do this by setting the useOverlapForQuestInteractables? to false on the AC_QuestSystem_PlayerController attached to your player controller. Keep in mind that this option is actually relayed to the World Quest Helper when the player controller component creates it, so if you are manually adding the World Quest Helper to your level you would set the value of this variable at that location instead.