Binding to delegate without hard reference?

My multicast delegates don’t seam to be available unless I cast, but that creates a hard reference in my other actors. I don’t want hard references as it bloats memory like crazy. Is there no way to expose the delegate without casting? I do have the actor that has the delegate, but it’s a generic (ActorComponent).

Delegate

Actor Component in other Actor
image

Is there really no way to communicate like this without casting and generating hard references? I’ve done pretty well isolating things using interfaces which keeps my actor memory footprints absolutely miniscule, but this has me stumped. I need a dispatcher so I don’t have to do a GetAllActorsWithInterface call.

1 Like

Anyone have any suggestions? I’m stumped here. Can’t seam to find a workaround. Is this just a problem for BP delegates? or is there a better way to go about this? Basically when a dungeon has been disabled I need to turn off behavior on some other objects. Delegates make sense here, but not if I have to hard reference. Would be nice if I could define the delegate in an interface then I could bind to it without casting.

@Krileon
It could be an issue with the Blueprint delegate, as I know they Auto-cast their references. The delegate does seem like the best way to go about your issue, though, so it may be worth checking out the C++ implementations. If you want a link, I’ll throw you one:

There’s a lot going on, and a lot of control you have - with both events and multi-cast delegates.
I hope this can help!
-Zen :vulcan_salute:

That might complicate things since my game is entirely in BP as is. Just strange I can’t bind to the delegate without doing a cast. It just doesn’t show up at all.

Turning off context sensitivity lets me add the delegate event, but it of course can’t work since I can’t set Target even though I have the Target as a generic Actor Component.

1 Like

If interfaces could define input/ouputs of type Delegate that’d also work as I could pass that delegate along through an interface function, but alas does not seam like I can. Really bumming me out these limitations! :expressionless:

Only solution I can think of is add my delegate to my game mode, cast it, then use my gamemode as a event manager. It’s already going to always be loaded into memory and all it’ll have is my delegates so the hard reference shouldn’t matter. Will also review making my dungeon manager have no references and just returning a reference of it throughout my usages.

My alternative is using get all actors of interface and itinerating over them, but that seams like that’s a bad idea. However this is only being called when the game is basically over so maybe it doesn’t matter.

If anyone has any other ideas I’m open to some suggestions here. Trying to keep this in BP though. I don’t understand why interfaces won’t let me select Delegate as a variable type. The below for example works.

image

But that’s impossible for an interface since I can’t select delegate as the type. This would solve all my problems as I’d just pass the delegate to the interface function, which would bind it.

Looks like my only option is to buy a dang plugin for this. Uhg. I really hope to see improvements to BP delegates in a future UE5 release. We need to be able to bind to delegates from anywhere using a weakmap. I don’t want hard references all over the place as that’s a solid way for memory management to completely spiral out of control.