[r103.2] Object list not updated in loop (?)

Bugs will be moved here once resolved.

Post » Mon Sep 17, 2012 2:26 am

Hi, I wonder if it's by design or not, but I think that it's highly unexcpected.

This capx just shows the problem in a simple way, but I stumbled upon this bug while working on a bsp tree algo.
Basically I create 2 new sprites from existing ones each loop iteration. And only the first iteration works.

So work around it I had to use the game loop instead to access an updated object list each iteration.
If you're curious you end up with something like for now that.

I think I read somewhere that objects are only created at the end of the event block containing the create action.
But I think in loops cases it's too limiting.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Mon Sep 17, 2012 2:56 pm

This is because of the breaking change where created objects are not really created until the end of the next top level event. As a side effect the object count is not updated either until the end of the next top level event.

I think this has been reported a couple of times now, which is reason enough to fix it, but unfortunately this will be another breaking change (since I am aware some projects already depend on the way it currently works).
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Mon Sep 17, 2012 3:24 pm

@Ashely
Yeah I thought it was something like that. "The nex top level event" it's indeed very problematic for pseudo-random generation algorithms or any recursive stuff.
Ideally, we should be able to pick and do overlap and parameter checks as soon as an object is created in the flow of actions.
Hope you'll manage to work your magic on that (:
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Wed Sep 19, 2012 9:05 pm

@Ashley any word on this? I'm having a not very fun time trying to fix a game for a deadline.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Wed Sep 19, 2012 11:21 pm

It's only the object count that is affected. It's fixed for the next build, which should be out by the end of this week (hopefully tomorrow).
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Wed Sep 19, 2012 11:58 pm

@Ashley, so you are saying that you have only fixed the object count? Or has instance spawning/picking been reverted as well?
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Thu Sep 20, 2012 12:06 am

@sqiddster - yes, only the object count - it really is hard in the engine to handle created objects differently without causing other projects to crash. It's a shame it had to change, if it had always worked this way the problem wouldn't be such a pain...
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Thu Sep 20, 2012 12:41 am

@Ashley That's fine, just making sure. ;)
Keep up the good work!

I'm not quite sure how to deal with looped creation of objects now, however!
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Thu Sep 20, 2012 1:50 pm

@sqiddster - the best workaround is to make sure everything you do with an instance spawned in a loop is handled in subevents to that event only, rather than subsequent events. That should still work fine.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Fri Sep 21, 2012 2:33 am

@Ashley
I showed you the issue in my capx with displaying the object.count value, but if I foreach the object it won't take the newly created ones as well. Is it because the foreach is based on the object count? (this question's aim is just to be sure that we won't end up with object count corrected but foreach still broken (: )

and @sqiddster, if you need something that is recursive, like
[code]on start of layout
while
object.count < limit
foreach object
    -> create object[/code]
you can distribute things over more than one tick
[code]object.count < limit
foreach object
   -> create object[/code]

(note that object:spawn is the same as foreach object -> create object)
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Next

Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 3 guests