I’m looking through my projects and snippets and thought, that could try sharing some on the Marketplace, so I’m working on putting by Blueprints in separate project(s) ready to share.
Since I learned everything by myself - some of it is a mess and I have lots of cleaning to do.
Now, the problem: I want to share a Blueprint, that works with actor(s)'s or player’s components, but I have Cast To implemented, and I don’t know how exactly the final user will use it.
For the sake of this post let’s say my plugin influences the player’s camera when he triggers something (cause it will be easiest to explain).
So in my projects I can just have functions/events that on trigger will Cast To MyPlayer BP, then get the Camera component and done - all the logic comes after.
But once I share my BP - that hardcoded cast to MyPlayer BP wont work, right? The other creator using my BP will have different class for player (eg, MyLittlePony) or even the same name, but different implementation, thus this will never work. Even if I add the parameter to my BP - Actor or whatever, that creator will just reference his player - at some stage I need to cast to something and check for the camera. Or not?
So what I did at the moment is creating an Interface I_Player with a function Get Camera that has only one output pin (Camera), and in my BP I’m checking, if the triggering actor has implemented that interface, then just calling Get Camera (inside my BP to be shared) and voila!
Question1: Is that the right solution?
Question 2: What is the common practice to do that?