Do "ForEach Loops" and "Fast Loops" use more memory than new objects?

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.
  • I've encountered an issue (that I've had MANY times before), with multiple instances not doing their own thing. Basicallu, I've got an object (dust cloud) that shoots out in a direction when you destroy an enemy. It works all well and good, apart from I need 4 instances of the object. Each one shooting in a different direction. Setting "Initial direction" will just make them go in one of the directions at random, and if I set each object a direction when they're created, they'll all set to the latest direction specified.

    The only workaround I've found for it, is to create 4 different dust clouds, each with their own direction. I'm wondering if perhaps using a "Fast Loop" or "ForEach Loop" for this type of thing, would be less strain on the engine? If so, how would I give them all a direction using one of those methods?

    Thanks!

  • Regardless of which one uses more memory, in this situation you can go ahead and use any of those methods you want without seeing a performance drop. It takes a lot of loops to cause noticeable slowdown, running constantly. I believe i've had around 700 (the result of nesting on the x,y and z axis) running at once, checking from an array and creating/destroying tiles if necessary in my level editor before (but I wised up and starting rendering the edges only as it scrolled in the end ;)) and I was still only dropping from 60 to 40fps.

    As long as the loops aren't using intensive calculations, changing object scale or in general doing memory-heavy stuff, you can run thousands of them.

    Best person at writing incomprehensible posts. Edits are a regularity.

  • You can use a ForEach loop for this and it won't affect performance at all. As casleziro said, the loop itself won't cause any performance drops. What you do in those loop might, but changing direction is not resource heavy at all.

  • You can do it wothout loops, given their collective behaviour is symetrical/ semi-symetrical.

    After you create the clouds, give them each a unique ID and then set Dir based on this ID.
    ...Or, you could create a seperate Event for each instance that is created ( and apply specific properties to each or either one ).

Participate now!

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