Dynamically Spawn static meshes and print their data on hover

Hello, I have created a structure with the following variables; Static mesh variable, Asset name string variable, and assetid integer variable. I have over 80 static meshes. I am able to spawn the static meshes in a function with a loop in an actor blueprint, however, what I would like to achieve is to be able to be able to have an on-cursor over event on each of the static meshes. When any of the static meshes are hovered on in the game, I would like to have their associated name string and assetid displayed in a print string at the least. Can I kindly get some assistance on this?

Enable mouse over events in the Player Controller and dynamically bind an event dispatcher after spawning.

2 Likes

Can you kindly help with a visual example? I am a bit new to this.

  • in the Player Controller:

image

  • or someplace else:

image

  • when adding SMCs:

The meshes must block the Visibility channel, or choose another channel.


When any of the static meshes are hovered on in the game, I would like to have their associated name string and assetid displayed in a print string at the least.

Override the SMCs and feed it data via an exposed variable when instantiating:

image

You’ll be able to us the custom event as in the example below or, since the components have their own graph and functionality, they can do it themselves internally.

As depicted in the image above, I seem to be getting only the last asset name because the loop runs once. I would like to get the information on that specific asset when hovered.

This is the component you touched:

You need to associate data with it. That’s why I suggested exposing data on the components. So it’s the component that holds everything, no need to ask the DT for anything. It’s just used to pipe stuff into the component.


Alternatively, pack them into a map.


Here’s a more complete setup:

  • extend an SMC as suggested above:

image

  • inside this component:

You could just print the data here. Or you could add a custom event dispatcher should you wish to access this data elsewhere without casting.

  • when you instantiate, bind to the custom dispatcher (or to the native one and cast):

This way you end up with a component that can not only show a mesh but also hold other data and dispatch it when asked to.

Thanks very much! the event dispatcher method works perfectly! :grinning:

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