Traps and triggers

I’m making a game where the user has to deactivate traps.

I’m making a series of triggers and a series of traps. An example would be a pressure plate (trigger) and an arrow trap (trap).

The pressure plate is just a flat box with a collision box on it. I’d like to connect any trap to the trigger. To do this I made a public variable with an actor reference.

That way I should be able to reference the connected trap when the trigger is, well, triggered.

Normally I’d just take the referenced actor, cast it to it’s appropriate type, call an event and there we go (I think). The problem here is that due to this setup I do not know what class to cast it as, as it could be any trap. Making a manual cast to arrow_trap would be wrong, because it could be a poison trap.

All traps will have a “activate_trap” event. In that sense it doesn’t matter which trap we’re talking about.

Here are some of my thoughts:

  1. Maybe using a blueprint interface to call a function in the trap referenced by the trigger
  2. Maybe making a trap class, making child classes of that and hopefully that eases calling the functions

I am unsure how to solve this problem. It sounds like a basic thing to do?