How do i cast multiple pawns to a widget interface?

Hello, to whom this may concern.

I am attempting to modify an existing project (Archviz obv.) I have been able to modify most elements so far with a bit of trial and error but i have reached a wall in the next functionality i am attempting to create. Apologies if this construct is allready well known but i will be trying to explain as much as i can so as to reach a greater audience?

PROJECT:

An intefcae that lets users interact with an architectural project and select appartments and get more info, ie: price, interior images, etc…

EXISTING CODE:

  • 2 pawns exist - BP_Main explorer PAWN and BP_360 Explorer PAWN.
  • The first is the main pawn and the second CASTS a second pawn hidden under project (with updateable 360 texture) to a widget interface that opens as an overlay on screen. This allows people to view a 360 degree “image” of the interior of said selected actor.
  • Each appartment is an actor with its own BP that can be filtered and various supplementary info can be viewed through a series of actor variables.
  • To cast the 360 image, the button calls upon a custom “switch pawn” event in the main BP controller. But it only controlls 2 pawns and i dont fully understand the logic behind this piece of code.

WANTED:

I would like to add a functionality whereby i could add a button on each appartment that would cast a camera/pawn of the view they have on their balcony to the same type of widget overlay that the 360 interface currently uses.

I could render a 360° image of each balcony and update the image on the widget interface, sure, but what would be cooler is if i could directly cast seperate pawns into this widget interface.

This means casting multiple cameras/pawns (at least 20 to 30) to the same widget interface…

CURRENTLY:

I have currently added the button, added a variable to the appartment actor and created a couple of cameras to cast. Now the hard part.

Is there a way of using an info structure (that would contain the names of the cameras) to cast actor specific cameras to the same widget interface? A bit like this but instead of updating the 360 image it would cast a new camera to the widget interface?

I hope i’ve been as clear as possible and thankyou in advance to anyone who can help!

Sincerely

since you have multiple pawns its better to have the pawn update the widget this way you can have any number of pawns and on their BeginPlay the can get a Ref to the widget and call UpdateButtons or something. (note widget must exist at this point)

then in the widget, remove GetActorOfClass and use an interface to pass through the structure data

Hello Auran,

Thankyou for your response. If i understand correctly each pawn needs to be an actor with its own BP that calls upon the widget?

  • Button in info begins an event stored in the pawn itself (maybe i can create an enum that stores all pawns and add them individually to each “appartment”)
  • That pawn calls upon an overlay of the widget and casts itself to the widget?

The widget currently has very little code, just the close button that retaurns the pawn to the original main explorer (and closes the widget overley of course)

The main code comes from a custom event in the main explorer pawn thats called upon by the info widget.

So instead of the event being in the info widget, i should have the event directly inside the pawn actor? Have i understood correctly?

Do you have any examples by any chance?

all pawns are actor so no problem there
each pawn should have its own data so it makes sense to store it there
on begin play the pawn can register itself, either directly to the widget (again if created) or maybe to a middle manager like the GameMode (probably a better idea)

the widget button should be modular (just takes its the info and returns if clicked)
the widget container should manage them (lets call it a scroll box)
the container can then bind to the manager (gamemode) and update when a new pawn registers itself by creating a new button and adding it to the scroll box

this will now work for any number of pawns added/removed dynamically