So Iv been applyingfrom everything i have read to have a good mix of interfaces and casting where appropriate.
Why can I only access interfaces using actors as get actor of class? (which I believe is a downgrade on performance due to going through the actors in level please correct me otherwise)
I have tried self and many other forms of targets to no avail and would really appreciate someone explaining to me how to make this more performative.
If you use ‘get actor of class’ then you’ve cancelled any advantage of using interfaces.
You only need an actor reference to talk to it with an interface.
Can you give me a usage example maybe?
A classic example of interfaces is interaction with objects. In that case, you’ll be getting the reference either from a line trace or overlap. Very often needing to know references up front doesn’t happen.
Communicating between widgets and stuff in the map is a bit more fiddly, because you can’t give the widget a reference beforehand.
One good route, is to create the widget either from the light, or an actor in the level that does know about the light. Then you can either pass a reference to the light into the widget, or a reference to yourself ( the widget creator ) and the widget can talk back.
Generally speaking, communicating between actors with interfaces is just that. ActorA passes an interface call to ActorB. They never know what kind of actor the other is.
Ok, soo in theory should i just be able to create a random actor variable and pass that as a target in my interface message?
I just finished moving a ton of logic out my level blueprint and using interfaces, I just need to find a more performative option than get actor of class haha!
The moment you have a ‘MyBlueprint’ reference, it’s game over …
Interfaces are no more performant than casting. The problem with casting is, once your project gains size, it will be riddled with cyclic references and you won’t be able to load anything in memory without half the project coming with it
I tried with the get all actors with tag but nothing. could it be because the BP_gameover is already in the level so when it sends the message on begin play the BP_NPC isn’t spawned yet? but with a tag i thought that wouldnt matter.