Faster Multiple Object Instances

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • tl;dr

    To make long story short, my code lags with lots of objects and I'm looking a way to speed it up. Pleas Help as it is for my Uni project MMF2/F2.5!

    ****
    Current Source:
    Please login to see this link.

    In short

    - Source = Planet
    - Object/Children = Satellite
    - Each Planet can have random number of Children (0-16)

    With 100 planets there can be betwen 0-1600 satellites and each follows their independent Planet on specified distance (planets can change size real time, and level also scales).

    Proposed solutions:

    1) Attempt to count only Satellites/Planets for visible (in range) but how to limit loop to only that amount, and know specifically that I refer to them?

    2) Instead of loops use array (proposed by snail) but I never used them in such scale and... I even don't know where to start

    3) Any other idea which could speed it up would be wonderful.

    End is near.

  • You don't need loops for this at all as you can set the satellite's alt.values to the orbit centre of each planet as it's created, then just run the code for the orbiting actives based on these values.

    Example:

    Please login to see this attachment.


    Easily does >2000 satellites on screen at once.

    Hope this helps!

    Please login to see this link. | Please login to see this link. | Please login to see this link. | Please login to see this link.

  • So I tested it and it is all cool but I tried before with the IDs, and it didn't work out for me (dunno why).

    In provided modified example I added a scalability of individual planets and it only works for me in this scenario - where individual planet is selected and we do action then.

    In any other instance (like trying to do a loop or always condition) not all satellites were moving to corresponding position or only the latest one did :(

  • For Each loop is one of the ways to go, I thought about it yeah. We will see. ATM I need to make it working in MMF2 and it doesn't have built-in ForEach loop (I know about the extension, thought ;) )

    Still any other ideas/concepts/solutions are most welcome - I credit everyone and look for most efficient one. I will give some of my own results after I wake up, lol.

    End is near.

  • To optimize your current system two things:
    1) Use For each loops
    2) Use Groups. Put all your updating code in a group and disable it automatically at the end of the group with a "On group activation" or in the loop itself if there's only loops. Then before executing your loops or foreach loops, be sure to activate the group in which it is located.

    The group solution will prevent MMF to browse all loops in search of the right one. In my case I save between 5-10 FPS.

    Please login to see this link.

  • Sphax I am aware of Group Activation hack, however in total I run 2 loops in my engine - 1 for creation of sattellites (which is deactivated) 1 for their positions (which is the issue here).

    I will need to have a look into that For Each loop, but the extension is not available anywhere online to download (Ross website directs to Clickteam, which after refreshing is not supporting any of developers subpages .info/username

    Also AFAIR ForEach MMF2 is not XNA compatible, is it changed for 2.5? Or 2.5 even doesn't have XNA support?

    End is near.

  • OK I recreated examples provided in MMF2 (I will still play with them) and there is a small difference in performance:

    MMF2: 6862 Sattellites
    F2.5: 7363 Sattellites

    Still both are running pretty smooth and scaling seems to work (yet its slow motion, but what to expect in refreshing of fewK objects... So thanks a lot for your ideas. I will try to experiment further with ForEach!

    End is near.

  • Since you only need to update the planets and satellites on user input running this update loop for 100 planets is not a problem. Of course when in the process of zooming in and out it will eventually drop your fps. I don't think there's a more efficient way to do it, but I may be wrong, anyway here's an example with built-in foreach in F2.5.

    Please login to see this attachment.

    Please login to see this link. | Please login to see this link. | Please login to see this link. | Please login to see this link.

  • OK so I run some tests on multiple variances of the moons/sattellites and below I present the results:

    ***Please take into consideration that I remade all examples provided here under MMF2 and modified them to do same operations (Set Random Scale value, instead of slow step increase/decrease as in Complex case)***

    I run several tests for each method of moon allignment (3 runs of 3) and provided average variables below (Top most Planets, Satellites/Moons and lowest most FPS during their re-scaling).

    Following methods were used:
    1) Pick One of + Variable
    2) Fast Loop + Spread ID
    3) Fast Loop + Pick One Of (No Variable!)
    4) For Each Basic (The most basic For each I gather)
    5) For Each Complex with Effects on (seperate loops for scaling down/up)
    6) For Each Complex with no Effects (seperate loops for scaling down/up)

    It seems that the most FrameRate resistant method is without any FL/FoE as objects are pick invididually so there is a little lag (you can see individual planets being rescaled) however it doesn't require lots of power so it is a good alternative for low-end platforms (Flash/Mobiles) with some extra coding could suprisingly be the most efficient method.

    It also occured that FL+Pickup is nearly as efficient as For Each Basic, which sounds as a very good alternative for me - as For Each I got is not supported under XNA, and I doubt my lecturers would be happy to see unknown to them For Each extension (lol).

    Yet For Ech Proved to be able to handle most objects with highest framerate +for ross for making it, as it works, lol.

    Pick One Fast loop FL PickUp ForEach B ForEach C ForEach N
    Planets 926,3333333 912,6666667 916 919,6666667 820,3333333 917,3333333
    Satellites 6900 6819,333333 6810,333333 6863,333333 6142,333333 6819
    Refresh 45,66666667 14 15,33333333 16 19 16,33333333

    Please login to see this link.

    Comments Individual pick slow with over 5 objects - lol

  • If used well pick at random can be great for handling instances, especially on slower platforms. I find that any time I use loops in iOS everything grinds to a halt, so investigating other solutions is a must. "Slow looping" is also a good alternative.

    Please login to see this link. | Please login to see this link. | Please login to see this link. | Please login to see this link.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!