is using a psuedo cast to function (by using Interface functions) a good idea?

for context I am using BP and UE 5.3
So I heard ‘Cast To’ nodes are bad. Like for example I have a custom player controller class called ‘PC Core’ that is child of the player controller class. I wonder if I can use interface functions to make a psuedo cast to node and does this make it what you call a soft ref and is that desirable?

So instead of using ‘Cast to’ node, is it a better method to use an interface function library and make an interface function called ‘Psuedo Cast to PC Core’ where the output pin is ‘PC Core’ , then have the ‘PC Core’ class have it inherit this interface function library and have it use this ‘Psuedo Cast to PC Core’ interface function where attached self ref to the output pin.

Here is a picture of what I am talking about:
1st pic is in the custom player controller class PC Core


2nd pic is calling the psuedo cast to in another blueprints
image

Also any time I want to do the ‘Cast to’ node I can use this interface function instead?

1 Like

What’s supposed to be ‘bad’ about casting, is you end up with the blueprint that does the casting containing a reference to the casted object. The casting creates a dependency between them.

But here, you still have a reference

image

So you’re back to square one, I’m afraid… :frowning:

If you look at the blueprint ( the one calling the interface ), it will still have a connection to ‘PC Core’.

You can avoid this by only calling interfaces on actor references ( or generic engine types ), and passing information over the interface.

1 Like

lol forgot the output pin is a ref, thanks for pointing it out

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.