Toggle visibility and change character

So I’m trying to setup a way to change character as well as change what they see in the world around them.

By pressing space I’ve managed to create 2 pawns that you can switch between.
What I want to happen as well as that they see different things. So toggle the visibility of certain objects around them.

I tried setting up something in the level blueprint for pressing space but then that takes priority over the switching character mechanic.

I tried making a blueprint which has ‘enable input’, but that gets ignored if used.

Would anyone know a good setup for this? Maybe I’m just thinking too complex right now. Thanks in advance!

if you want two input events to fire when you press a button you could just disable consume input. this will allow many events to work from the same key press.

personally however your situation sounds to me like a good instance to use a interface. when you press space you call a interface event which will get triggered on every actor that implements the interface. so basically one script to affect all the things. you can even implement the interface in the level bp if you wanted. a major benefit of this approach is you only need a input event in one place which is good practice and makes for easier debugging later.

I would recommend moving the input event out of the level blueprint and into the player controller (use the same controller for both types of pawn).

As for choosing which objects are visible to each pawn, I’m not sure the best approach.
The first idea is to set a Tag on each object as either “PawnTypeOneCanSee” or “PawnTypeTwoCanSee”,
and upon Possess event of the pawn class it can GetAllActorsWithTag for the one tag and set Hidden in Game to true on those, and GetAllActorsWithTag for the other tag and set Hidden in Game to false on them.

By using the Possess event then it does this at the point your playercontroller takes control of the other pawn.

But I think if there are a large number of objects to switch the visibility of, then this approach will cause the game to freeze every time you switch pawns, so I’m trying to think of a more efficient way that doesn’t require you to set tags and loop through them, like maybe some special way of using materials or actor ownership (OnlyOwnerSee checkbox) or something, but I haven’t come up with anything yet.