Picking objects by UID or Local Variable

Get help using Construct 2

Post » Thu May 14, 2015 10:31 am

Hi guys

I have discovered that different way of picking objects gives quite different performance results
I have 2 objects, in local variable of one i store the UID of the other
Then i want to pick them together, every pair by itself, and here's 2 ways i can do it:

Image

When i multiply the pairs a bit i got drastical difference in FPS

with Group1 I pick the second object by UID and got 60fps
with Group2 I pich the second object by Local Variable and got 10fps

Can anyone explain why is that?
Thanks
B
12
S
3
G
1
Posts: 120
Reputation: 1,829

Post » Thu May 14, 2015 11:43 am

Could it be the difference in events?
In Group one you have a pick event, while in group two you have a compare event..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu May 14, 2015 1:01 pm

Not sure what is the difference in computing it....
the actual effect I get is the same both ways - for each of the sprites i got the pair selected and can interact with it.
B
12
S
3
G
1
Posts: 120
Reputation: 1,829

Post » Thu May 14, 2015 1:23 pm

One possible explanation:
In the first case, Pick by UID knows that there can only ever be one object with that UID, so it will stop once it finds it. In the second case C2 can't know that, so it has to check every Sprite object's variable to see if the value matches or not, as there may be more than one Sprite with that value.

It's also likely that C2 has an optimal way to pick by UIDs since it's a common operation.
ImageImageImage
B
71
S
22
G
257
Posts: 3,790
Reputation: 142,696

Post » Thu May 14, 2015 1:52 pm

Well that makes a lot of sence, cheers.
Now will have to walk over my code for some optimisations.
B
12
S
3
G
1
Posts: 120
Reputation: 1,829


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 3 guests