oh… basically ActorA has been destroyed and once done must be replaced with ActorB. But to do that I need to spawn ActorB with a owner in the same levelmap using LevelBueprint.
It doesn’t work spawing from ActorA so that’s why I need to use a “bridge” like GameInstance
So in your example:
ActorA send data that has been deleted
GI listen and resend data
LevelBlueprint (of each levelmap, that is what I need) are listening
All I’m saying is that you don’t need to manually create and call a dispatcher when an actor gets Destroyed. It already exists and will be called. You just need to register it. As seen here:
You add custom dispatchers when the available events are not what you need. Or when you need to dispatch specific data. Destroy is an event that even sends the reference of the Destroyed Actor.
as you can see ActorA has been hit, an after few hit, it destroyed. Then it has to start with a set of operations, one of them it is to say to the current level BP that it has been destroyd
I’m currently trying your GameInstance just created a custom event which calls the ED in GameInstance.
The problem is that the levelBlueprints don’t listen to the gameinstance when the ED is firing
Blueprints and actors load sometimes in strange order.
Level Blueprint is always first, when it starts some other blueprints may not be yet loaded.
For debug such issues (in level blueprint) add check if other actor exists and is loaded, then print result.
On top of all that loading is sometimes diferrent in editor game and in released/standalone game.
So do checks for all missing references.
These 2 are somewhat good reads on the above-mentioned subject:
One note, the Garbage Collection section was not updated when the GC manager (orwhatshername) was introduced / rewritten (around 4.16 - 4.17 perhaps?) so that part may be inaccurate. Probably irrelevant here, though.
What if you have two levels with same mechanics?
Making inherited game mode with new level mechanics would be better.
Btw. I know that you know.
Just really curious why ppl are doing code in level blueprint.
Anything i can think of can be coded better elsewhere.
And on top of that level blueprint code is nightmare to maintain.
PS. (I did not read whole topic again, so i may have missed some answrs)
But, i just remembered some small and dirty hax for similar cases.
When i have trouble with referencing actors (hard to get that pointer/reference).
For those cases i create variable in one of blueprints (game mode or something),
Then from actor i want to be referenced i set that variable to that actor pointer.
Now anything that needs that actor can just get what it is in variable.
Yes this is dirty hax, because if referenced actor gets reloaded, pointers may be outdated.
I’ll admit I don’t know what OP’s issue really is. The script I posted is from a working example and can be simplified further by removing the Custom Event in the GI and calling its event dispatcher directly.
Actor calls GI’s dispatcher → LB receives GI’s call. That’s pretty much it.
Apart from working in level reloading and ensuring the order is correct for standalone, that’s really it. I don’t think it was explained how the levels are supposed to operate or I missed that.
When talking about hacks (which, imho, are unnecessary but may be necessary for something unorthodox), one can always place an actor with a tag in each level, fetch it by tag and bam, you have access to the level blueprint.
Ok I have to fix the point. As was partially right… I mean.
In my case I’ve been force to use 2 Dispatchers because just using one doesn’t work, because of the level BP.
So ActorA sending data - First LevelDispatcher receive data and it pass data to an event, the second dispatcher here is the only one able to communicate with levelBP
Now works!