How to put the same behavior on any actor? (speech bubble dialogue)

Here’s the scenario. Let’s say I have a number of actors in my game, all who I want to be able to speak with a dialogue bubble above their head. See games like “A Short Hike” or “Night in the Woods”.

Most of them will be NPCs, but some of them might be be an inanimate object, or an object with unique functionality (which means a base “NPC” class doesn’t seem to be suitable for this).

I know how to make speech bubbles and drive the dialogue - my goal here is to make a modular “component” I can slap onto any actor to make it talk. I just don’t understand how to execute that.

In a broad program design sense, how do I set this up? By using Scene or Actor components? Interfaces? A dialogue blueprint that I then put inside the actor I want to speak?

You can use an ActorComponent, from there you will have all it function (start , end dialogue etc)

Then just add that actor component in your npc bp or non npc bp.

From your main character bp, you can call that actor component with an interface and make use of an enum like this:

at the end it mostly the same using a parent-child method or actor component, we just reusing the same function.

1 Like

Thanks for this - it’s very similar to what I already have except your example includes some cool switching which I might borrow.

My main concern is setting up the NPCs or things being interacted with. It seems like the only way to setup an interactable object is to manually add my collision detector, overlap events, overlap logic checking, the interaction widget prompt, on every actor. Doing this by hand for everything is a lot of repeated work and makes the system nearly unmaintainable.

Am I thinking of this wrong? Should the player be in charge of the overlap, the prompt widget, etc?

1 Like

I seen other dev making collision interaction for each actor bp, but personnaly i prefer to add it from my main character so to avoid indeed these repeated tasks and seem for me cleaner :innocent:, so yes better all event interact from your main character.

Then these interact event will call the overlap actor interface.

1 Like

Thanks for your help - it’ll mean a little bit of refactoring but it does keep most of the stuff in one place - all the interactable actors need to do is exist with the interface and accept the players events!!! From there, I can easily use ActorComponents to create standardized behaviour logic where needed. Thanks again!!!

1 Like

A pleasure :innocent:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.