I’ve been doing more and more work with blueprint interfaces but I’m struggling to get a certain configuration to work. I have 3 blueprints
BP_NPC_Shop - Contains and mesh and a camera called NPCCamera (Parent: Character)
BP_ThirdPersonCharacter - The starter content blueprint for a third person game. (Parent: Character)
BP_NPC_Shop_Building - The building with a box collision in it.(Parent: Actor)
The idea here is that:
Player character overlaps with the box collision which allows them to press the letter E to interact with it.
When they press “E” the camera switches to NPCCamera.
I had this working previously using “cast to” but I really want to make my blueprints more efficient so I’m making the change to blueprint interfaces.
I have made two interfaces:
InteractInterface
SwitchCameraInterface
Starting at the BP_ThirdPersonCharacter I have implemented an interface called InteractInterface which interates over the overlapping actors when E is pressed and looks for those that inherit the InteractInterface which removes the use over the overlap event for the box collision. This blueprint has the InteractInterface added to it.
I then have the NPC_Shop_Building blueprint. When the interact event is sent off it ends up here and prints out a string saying “Interact Event”. So far all of this works until this point. I included a reference to the Switch Camera interface but it doesn’t seem to do anything.
Finally we have BP_NPC_Shop blueprint that has both InteractInterface and SwitchCameraInterface added to it.
So, it works up until a point an d then I’m a bit lost. In NPC_Shop_Building I tried to call this event hoping that it would print out the string “You’re in the BP_NPC_SHOP” but I cannot get that to work. I’m using strings for the moment as to not clutter my screenshots with logic for camera switching.
My questions, how can I make this all work, I feel I’m part of the way there but there’s a missing piece that no doubt is a result of my misunderstanding. All help is appreciated.
Self here is the NPC_Shop_Building, right? That’s the BP in the pic above - you’re sending this message to the building, not to the BP_NPC_Shop.
How does this building know which Shop’s camera to switch to?
how can I make this all work
Many ways. Depends on the scope and how you design the whole thing. Are there more shops in each building? Is it all sitting in the scene or things spawn dynamically?
To identify camera use game tags for eg:
.camera.NPC.shop.camera_1 …
.camera.player.3rdpreson …
.camera.NPC.shop.builiding …
make some actor that holds this tag. and is used as location of camera. You can use inheritance to have different behaviors for that actor.
This actor hooks to dispatcher in game mode, or player controller, or something that is spawned in game.
In that you make dispatcher that sends tag you want switch camera to
and event that tells back camera transform etc.
when you want switch camera you trigger that dispatcher.
everything camera related is hooked to that dispatcher. and they switch cameras.
You can do switching cameras by having camera pawn that just snaps to transform of one of those actors
If you need 3rd party, fps some static camera for gui etc. Make different pawn for each case (separrate code, it gets more clear this way).
So all pawns hook to dispatcher, and if dispatcher tag equalls to pawn tag, it needs to be possesed. To posses/unposses make event in game mode, first unposses pawn, then posses new one (it probably works without unpossesing, but i am not sure)
If I move the event to say the BP_NPC_Shop, the event no longer triggers at all. For some reason it only triggers in the BP_NPC_Shop_Building blueprint. The interface is definately referenced in the BP_NPC_Shop it’s just not registering the event at alI.
If you look at my OP I’ve opted to leave the camera logic out for now just until I get get this interface to work and print out the correct strings
What does it even mean? You can’t reference an interface. You mean that it’s implemented, surely - and that’s fine. But you’re not sending the message to the right actor instance. This sends this message to this very actor: