Best Way to Reference Actors in Level

Hey all!

I’ve been pouring through tutorials on quest set ups, triggering different stages of the quest, updating events, etc. But it seems the only way I can get it to work is by setting specific actors in a level as a “checkpoint”

Example:

Have an NPC who begins a fetch quest of Item X, you go to Item X (which is placed in the level itself), overlapping with Item X triggers the next step of the quest (and dialogue system / page), you return to the NPC and they reward you / quest complete.

This works, but requires me to recreate this scripting every time (like for item X, Y, or Z) and it all lives in the level blueprint. Ideally, I would like this to exist in the NPC itself and the item is just set as a variable. However, if I try this and just set a variable as a reference to the item itself, overlapping with it in the level doesn’t register. Is there an efficient way to have this item register while living as a variable inside of a character?

Gav

You do not reference actors in level, its best way to have spaghetti code.
Instead you choose one blueprint to be master of whatever mechanic you want to code. For eg Game state is good choice.

Then you create dispatcher in that blueprint. And all actors in level that should be interested in when and what that dispatcher sends should assign event to it.
So you hook them all then call dispatcher and all those actors will do what they need to do in reaction to event.

Other direction communication (from actors to game mechanic blueprint) is easy you have one game state and everything can reference it.

Then there is more advanced version of it all: use blueprintable components. They add some platter code on top of usual stuff, but when done right its basically plug and play code.

So you could put all that logic inside blueprintable component.

  • npc has quest, you add that component to npc, set its state to “i have quest to give”
  • then player interacts, you attach same blueprintable component to player, but this time with diffferent stage of quest, and you destroy old component inside npc
  • and all that give and destroy component code can be inside that component. It can add new component to player, then kill old version of self attached to NPC.

Blueprintable components can also hook to dispatchers, so you can have game wide event that triggers all actors that have such component attached.

What is the problem with the Overlap?
Use the OverlapComponent Event in the NPC and check if it’s the same actor(item) as your referenced variable.

Thanks guys! With your help, I was able to figure it out - though, not sure if it’s the cleanest way (sorry, I’m super new to this and spend most of my time on the art side…)
@Raildex_ : The overlap worked fine, but I specifically wanted it to trigger once a player collected the item. Which is being destroyed as it goes into their inventory. Previously, it was just living in the level blueprint - based on the tutorials I’m following - but I wanted it to be more modular (and belong to a specific quest, be an inv item, etc.)
@Nawrot: Thanks for the help! I ended up putting the code in the item with a shared interface - when the actor gets destroyed (put in inventory) it triggers the next stage of the quest, then once you return the item the quest is completed. I can try moving all of that to just the component, again though, I’m pretty green when it comes to this.

How to assign blueprint actors of level properties in Unreal Tournament 4 Assault game mode?