Crash with dispatcher update #1035
-
Hello,
As you can see I pointed that it crashes with
Let me put here again the output when it crashes
As you can see it printed out Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 5 replies
-
hello again, So, my GameScene class has the member Now the challenge I am facing that is crashing is: I have a DamageSystem that has to listen that event that happened in the CollisionSystem, to tag those to entities with DeadTag. In other words, an event happening in a SystemA between two entities, has to be listened in a SystemB and set those entities with a DeadTag (because at the end of the game loop all entities with the DeadTag are destroyed). I am sure this must be very simple, but I am a bit lost. Thanks |
Beta Was this translation helpful? Give feedback.
-
hmm... I am using axmol framework, so I can't really pack an example that doesn't force you install axmol. I'll see if I can figure out a more software agnostic way to reproduce the problem. No worries. |
Beta Was this translation helpful? Give feedback.
-
I am trying to think how to make a pack fast and easy to debug, but I am not sure how. Do you have any preferred github repository that I can download with a basic game loop structure to try to reproduce what I am doing? edit: never mind, I think I figured out of to post a working pack to test very easily. I'll post it later |
Beta Was this translation helpful? Give feedback.
-
I'll try to explain again in case the issue is my approach (and I'll drop an example a soon as I can). I want to create an event when a collision happens between two entities in a CollisionSystem. When this happens, I want my DamageSystem to be notified, so the damage system puts a tag (DeadTag) in those entities that collided. And finally, my gameloop, in the last line check which entities have the DeadTad to destroy them. It is simple but I agree with you that my code doesn't help help understand the problem. So I'll try to simplify it. |
Beta Was this translation helpful? Give feedback.
-
Hello again. Anyway, here is a the complete code that will reproduce the error.
This errors with Thanks |
Beta Was this translation helpful? Give feedback.
-
Oh my god...I new I was doing some silly mistake. I though I was initializing the variable but I forgot this->registry = registry. |
Beta Was this translation helpful? Give feedback.
-
Yes, from now on I will.
This doesn't look very efficient right? or is it normal in game developement to subscribe and clear events everyframe? |
Beta Was this translation helpful? Give feedback.
Well, in this specific example you have a trivial error actually. Just replace this:
DamageSystem(entt::registry *registry) { registry = registry; }
With the following:
DamageSystem(entt::registry *registry) : registry{registry} {}
In the first case, you aren't initializing the
registry
data member and this explains the crash.No idea if it's also the same error as in you real world code. 🤷♂️