The interfaces contain functions declarations which can be seen as a contract of interaction for objects implementing them.
Simple said, you have to tell “run this method on this (instanced) actor (blueprint)” by given the target where the interface is implemented and the method to be executed on.
Depending of the thing you want to achieve you have to keep a reference of the actor by referencing them in your blueprint or thorugh interactions like collisions or linetracing where you get the reference of the object your interact with, which can be used to call the implemented interface function on it.
this is the first time I’m using blueprint interfaces so it’s really confusing. so far I’ve been able to get a reference to my character with an interface function but this message call always requires some kind of target which I don’t know how to get for regular actors.
You always need a reference. What communication method to use depends on the circumstances. You know how you’re going to select actors, the editor does not. You know which actor, the editor does not.
If you only have 1 → Get Actor of Class and you’re done. It’s lazy AF but hey, if it works…
What if i want to get access to a
blueprint that’s not going to be
interacted in any way
You can create a hard reference. You’d need to disclose more details. What is the scenario?
Let’s just say there’s fuse box in my game that has a boolean called poweron and there’s another actor that will use this boolean to determine if a door should open or not. These actor are static and won’t be interacting with each other, what’s the best way for these actors to interact with each other?
another way is to make the Fuse and the Door be the same actor.
if they must be separate actors, the Fuse can have a Child Actor Component hosting a Door actor
These 2 methods would work well, too. What to choose depends on the scope / modularity / level design / convenience or the way you personally like to organise it all.
Oftentimes, choosing something that just sits neatly in your head triumphs over something fancy.
Thanks, there’s another actor which is spawned at beginplay so its not available in the editor. I had to use get actor of class to get access to that actor, but it says its slow operation and not recommended to use. Is there a better way of doing this.