How to Setup a reusable context menu?

I have this situation:

  • I have a “Interactive Blueprint” (actors) (main class)
  • I have “Object Blueprint” (child of interactive blueprint actor) (doors, fences, containers)…
  • I Have a “Context Menu Blueprint” (child of Object Blueprint) (reusable context menu with UMG)
  • A Player interacting with ONE instance all this combined.

Considering:

  • “Interactive Blueprint” provide the basic interaction, as is Overlaping, is object clicked.
  • Each type of “Object Blueprint” have your own events, like Toggle Door, Toggle Lock, Create Barricade, destroy, etc…
  • “Context Menu Blueprint” is empty by default, and when player interacts with a “Object Blueprint” this fills his child with menu options based on his context.

Keep in mind that my main problem is to assign one of a door event to a button, with manageable way using “editable variables”.
How I can construct a Configurable “Object Blueprint” that takes an array of options and create the necessary buttons WITH ITS OWN AND SPECIFIC EVENTS?

I know how to feed the context menu with new buttons, the problem is in the “Event Bind” because doors have different events of the chairs. Also, I would like to say that the X door, has Open, Close and Lock. And the Y door has only Open and Close. I would not want to have to manually specify each event for each object type.

Hi, i am having the same problem right now


My current approach is:

  • i created a interface for each
    possible interaction
  • parent class
    creates events for all possible
    interaction and binds functions
    provided by interface
  • parent class
    implements states that can enable /
    disable interactions
  • child class
    implement interfaces for possible
    interactions
  • child class
    implement functions for interactions
  • context menu is generated by HUD class

When an actor is clicked:

  • parent class checks what interfaces are implemented
  • parent class checks states e.g. ( activate / deactivate )
  • parent class create buttons and binds events
  • parent class sends array with all buttons to my “context menu” HUD class
  • child class function is than called via the interface from the parent class event

This approach seem to work good enough if you have a low number of possible interactions but:

  • it gets very confusing when you have more options & states
  • lot of duplicate functions (code) in child classes
  • parent class has to implement events for all possible interactions
  • parent class has to implement all states of child classes

If anyone has a better approach it would be great to know :slight_smile:

Yes, I´m doing something similar but more simple.

Here we go.

1 - Create a Button Estage Structure, this will hold our button text, stage and action index.

63965-00+-ebuttonstages.png

2 - Create a BP Widget Context Menu. This Will hold our Container UMG and Show to Player

3 - Create A BP Interactive Object, add BP Widget Context Menu. Create 2 Editable vars, ObjectName and Buttons Array, Buttons Array is Type of Button Estage Structure.

4 - On BP Interactive Object, Create 2 Functions, AddButton And ConfigActions. The First Function will basicaly look for our WidgetContextMenu UMG and append butons on that, and the Other Will Determine What Action Index, will be Executed on each UMG button press. Create some Custom Events to Hold Our Binds.

The Final Setup Will be like that

Creating Buttons based on Config

AddButtons to Widget

Config Buttons based on action Index

Create some Child to Test, like a Door.
On Door, just use The Custom Event Actions to Call your especific function for each diferente asset.

Here is the [Complete Setup][6]. With a Door to test.
Anyone can use this on your projects, but wihout the art of UMG. Just customize for your project.

10/10 It work very well for me, thanks, you’re the best