Loop Behavior vs Constrain Behavior

jamie_cjamie_c ImagineLabs.rocksMember, PRO Posts: 5,772

In my new game I have been using the new Loop Behavior to continually Change an Attribute to a new value and it works the same as using a Constrain Attribute. Is anyone else doing this? Are there any opinions on which practice might be 'better' in the sense of easier on the engine and performance?

I've never had an issue with too many Contraints but just thought I'd try something different and it also seems to me to be more correct in a programming sense to use Loops.

Comments

  • HopscotchHopscotch Member, PRO Posts: 2,782

    @jamie_c, just did a test, since something similar was asked somewhere else.

    Surprising new results! Different from what it was sometime pre v10.4

                          Average Instructions per second
                         ----------------------------
    Constrain                  59,8
    Loop                       59,8
    Loop over Table            59,8
    Timer                      29,8
    

    That means, 1 update every draw call except for timers which cycle once every two draw calls.

    Same test with 60 of each caused NO loss in performance!

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772

    @Hopscotch‌, cool. Thanks for the detailed stats, very good to know! :)

  • TaoOfSaladTaoOfSalad Member, Chef Emeritus Posts: 83

    They are functionally equivalent for the case you described. Constrain will be slightly more efficient in CPU time and memory, but it would probably take a lot of instances before the difference is noticeable.

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772

    @TaoOfSalad, great, thanks for the info.

  • MantoManto Member Posts: 796

    @Hopscotch said:

    Same test with 60 of each caused NO loss in performance!

    Did you test them with 60 actors or all 60 behaviors in one?

    I tested 100 constrains in one actor and I'm getting around 18 updates (game loops) per second on iPhone 5 and 30 on my mac.

    100 change attributes in a loop behavior got 51 on iPhone 5 and 60 on Mac.

    So if you have multiple constrain attributes in one actor, you should group them using the loop behavior where possible.

  • HopscotchHopscotch Member, PRO Posts: 2,782

    @Manto1, absolutely, as each contrain is like a mini rule or timer. However, my test was performed with 60 individual constrains, loops, etc.

    @jamie_c, I did some more tests,

    only by spawning and destroying 30 actors every draw cycle could I get the frame rate to drop a little.

    Adding 10 particle system, with 500 particles each (particle lifetime 10s) made no impact on frame rate.

    GameSalad kicks a**!

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772

    @Hopscotch, yeah I'll say. Thanks for taking the time to do the testing, good information for us all! :)

  • HopscotchHopscotch Member, PRO Posts: 2,782
    edited May 2014

    Point is, adhere to optimisation strategies, but don't treat GS like some fragile egg.

    In response to another thread (someone switching to another tool) I threw something together, recreating the mechanics in GameSalad in about 4 hours. I will compromise quite a lot for this kind of development speed, but then again, if the end result is almost the same...?

    Rebel Twins, your game is FANTASTIC!, and no, this is not a template in the making. This is more to show that what you created is less about the tool than your artistic skill and attention to detail.

    @jamie_c, the structures in the levels above get spawned from tables to facilitate an endless runner with no loading screens.

    Again, not an upcoming clone, just my usual messing about!

  • nir3112nir3112 Member, PRO Posts: 316

    @Hopscotch said:
    jamie_c, just did a test, since something similar was asked somewhere else.

    Surprising new results! Different from what it was sometime pre v10.4

                          Average Instructions per second
                         ----------------------------
    Constrain                  59,8
    Loop                       59,8
    Loop over Table            59,8
    Timer                      29,8
    

    That means, 1 update every draw call except for timers which cycle once every two draw calls.

    Same test with 60 of each caused NO loss in performance!

    How did you do this test? I want to do it too..

Sign In or Register to comment.