Hello. A fairly basic question about how best to design events and a general “how do they work?”.
Am I right that if GDevelop encounters a condition that is not true, it will not check the rest of the conditions in that event and will instead move on to the next event immediately? So, that would mean that my first example is more optimal than the second. Is the sub-event approach (my second screenshot) unnecessary as a way of making sure condition checks don’t happen when not needed? Thank you.
I don’t know how accurate the responses are. I trust the users and it makes sense that you might prefetch objects or simply check if there are instances for each for each condition since if even just 1 condition references an object without any instances then the entire event is highly unlikely to result in a true condition. The only exception might be with NOT and OR.
Even if GD does something with each object that is mentioned in an event, it’s unlikely to effect things much if it’s just getting a list compared to checking collisions. It also depends on how many objects and instances are involved.
GD will do certain things that in other languages might cause a critical error. It can be difficult to just assume a condition or event might return a certain value since GD will create default values sometimes to prevent crashes.
The best way to check an assumption is through the profiler.
You’re welcome. I was surprised that I found it. I knew it had subevents and probably profiler. Subevents had 50+ matches. Adding profiler brought it down to like 8.
While what Keith pointed out is 100% accurate and what you deduced is better approach i want you and others if they find it in search while having same question
You have 2 things in your events
Object TrevorLarge
And object GROUP trevorGroup
IDK how many objects you have in group but let’s assume many
So you are right to limit it by checking one condition
BUT you are checking it for ONE object
If you for example have in parent event only animation of trevorGroup
And all other conditions in sub event
Then even so sub events will not kick in if animation of this group is something other than you are checking it for
You still 1st pick every single object in that group
So more sense would be to put in parent event that initialFootstepDelay timer
Since it is scene timer checking ONE thing and not multiple objects
BUT it would also have huge difference how many objects you really do have in that group
And we are talking about big numbers here like few k+ (which also vary depending on potato device or not)
Thanks for your insights, Zero. There are only 2 objects in trevorGroup. A large and small version of the player character (one for indoors, one for outside). They both have two just animations each: walk and idle. Sometimes I want to do something with only one version of Trevor, and I don’t use the group in those cases. Optimisation is an interesting topic. I think I am becoming am optimisation geek! But I think I worry far too much about it too.
Edit: I should not have used the group at all in this case because I only want to target trevorLarge. Thanks for spotting it!
Actually i say you are very wrong here
By chance that you used group here
It was perfect opportunity to illustrate the issue object vs object group when picking
And believe me sooner or later
Someone who will be creating idk farming or RTS or some horde game
Where are tons of objects to check
Will look find this question of yours
Read everything he will find here
And break concrete with his forehead in front of any1 who provided here ANY kind of tip how to de lag his game
I say you are right you worry too much about optimization
And for me it is stupid
Same as far too many users use health extension where they would be perfectly fine with HP variable
YET i need to be fair here
Is it good to worry about optimization only after your game starts to lag?
So is it really so stupid in fact?
I just find it stupid where in reality we should care for optimization with very 1st event we make in our projects
So we don’t need to worry later about it
And there is far TOO little info on how to optimize your project out there
So any info that can contribute to it is welcome in my eyes
My original post was about how events work: do they check all conditions in an event even if the first condition in that event is false. It wasn’t about object picking. So hopefully if someone else reads this thread they will come away from it with a little more information about the original topic. And Keith’s link is very helpful on that.
I certainly hope that someone who is making a farming game or RTS will not make some terrible mistake with their game because they read my post I’m not sure I understand how that would happen, based on my simple example event screenshots. This post is [Solved] because I got the answer to my original question. I am certainly very sorry if my event screenshots might lead someone to make mistakes in their game.
Edit: I have updated the screenshots. I would worry too much about the farming game and RTS otherwise!