Events only fire for first instance?

Discussion and feedback on Construct 2

Post » Thu Aug 22, 2013 4:22 pm

Sorry for the confusing title - wasn't sure how to phrase this better.

I am having a problem where events are firing the first time conditions are met but not the second or third time.

This post is an example of what I mean - the first instance meets the conditions and the events execute perfectly, but the second and third instances also meet the conditions and the events do not fire for them.

I set that problem aside and tried to do something else, and it turns out that again, the conditions are met for the first instance and the events happen to fire, but for subsequent instances that meet the conditions, the events do not fire.

Before I try to recreate this in a simpler fashion and submit a bug report, has anyone else had issues with this?

I have tried all manners of debugging, such as using For-Each, doing a function call each time a sprite is generated, other hacky workarounds, etc. but all to no avail. I have also ran this through another experienced C2 developer and he said he has had the same issues at times and thinks it also may be a C2 bug.Excal2013-08-22 16:24:29
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,234

Post » Thu Aug 22, 2013 4:36 pm

I can assure you that picking works correctly.
Perhaps its just the logic that's a little off.
ID suggest instead of using pick closest you should use instance variables with a counter for each group of instances.
Image ImageImage
B
169
S
50
G
174
Posts: 8,331
Reputation: 110,806

Post » Thu Aug 22, 2013 4:41 pm

In my case, that would be a bit cumbersome but I can see it as a viable workaround.

Is there a system expression for picking the least value when comparing instance variables? Like Pick Instance where variable X is the lowest out of the instances.
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,234

Post » Thu Aug 22, 2013 4:49 pm

Only way I see to pick instance by lowest/highest value is with a for each (ordered) and a stop loop thereafter.
B
71
S
30
G
25
Posts: 984
Reputation: 19,503

Post » Thu Aug 22, 2013 5:14 pm

First you will have to group the instances, and the best method to do that is with an instance variable.
You will then have to do a loop of all the groups.
That is.... unless you go at it from the front end, or creation, where for each group you give the head a variable with the count of instances in its group, and so long as that variable is less than x amount the group may add a new instance.
That would probably be better than the culling method.
Image ImageImage
B
169
S
50
G
174
Posts: 8,331
Reputation: 110,806

Post » Thu Aug 22, 2013 5:31 pm

I replied to the post you mentionned. It's not a picking problem, it's just that functions aren't called iteratively for each picked objects as you might think. It's one of those case where you have to explicitely iterate through your objects with a for each.Magistross2013-08-22 17:32:07
B
71
S
30
G
25
Posts: 984
Reputation: 19,503

Post » Thu Aug 22, 2013 6:12 pm

We've tested this, a for-each does not solve the problem.
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,234

Post » Thu Aug 22, 2013 6:29 pm

Submit us your actual problem, in a simple capx.
B
71
S
30
G
25
Posts: 984
Reputation: 19,503

Post » Thu Aug 22, 2013 6:33 pm

Quickly went over your .capx:

In your 'DestroyFurthestPart' function swap your pick conditions around. If you have pick furthest first, you will pick exactly one (possibly wrong) instance of hackpart and second condition won't really do anything. You probably want it the other way around.
B
24
S
9
G
7
Posts: 756
Reputation: 7,302

Post » Thu Aug 22, 2013 6:48 pm

@vee41!!!!!! How the...

You, sir, might have just fixed my problem. Those giant eyes of yours are definitely quite handy!
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,234

Next

Return to Construct 2 General

Who is online

Users browsing this forum: lkatkins and 12 guests