Perform actions when static meshes are clicked

Hello eveyone, newbie here.

I want to have some behaviour when some static meshes are clicked. In particular, I’m starting with two:

  • the player clicks a lever, it rotates and a door opens
  • the player clicks a key and and it disappears while a text appears on screen

I understood how to perform the single actions in code (e.g. rotating an actor, popping up a text), trace the player “line of action” and see if it intersects a component, but I don’t know how to link them.
Should I create a component (on the respective static meshes) for each event I want to trigger? If so, how do I link it to the player clicking it when it is in range?

Thank you in advance.

Also I want to specify that I’m building a first-person game, so there’s no cursor floating around.

You can use LineTraceSingleByChannel node

It uses your screen centre/aim cursor and a range that you specify. It returns that particular asset if hits one else returns NULL.

Thank you, I will investigate that!