Picking objects by UID or Local Variable

0 favourites
  • 5 posts
From the Asset Store
"Easy Local Notifications" enhances games with customizable local notifications.
  • 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:

    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

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Could it be the difference in events?

    In Group one you have a pick event, while in group two you have a compare event..

  • 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.

  • 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.

  • Well that makes a lot of sence, cheers.

    Now will have to walk over my code for some optimisations.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)