Search code examples
unreal-engine4unreal-blueprintunreal-development-kit

Create generic blueprint for multiple meshes


I am new to UE4 game development, but I am try to achieve something simple, but not sure what the right method is.

I have multiple meshes in my level, each mesh is a different shape. I want to add an onClick event to each mesh that populates a variable indicating which shape was clicked.

The blueprint that handles the on click will be the same for each mesh. I know I can create a blueprint and add a mesh to it, but how can I create a "generic" blueprint and add it to any of my meshes? TIA for any suggestions.


Solution

  • I solved this problem by creating a Blueprint Actor Component that I could attach to each of my shapes (static meshes), and I handled the onClick event with the following nodes:

    Example blueprint to handle onClick events  in Actor Component