Constrain Vs. Timer

TosanuTosanu Member, PRO Posts: 388

This is a quick question for performance, I hope someone knows it. If you need something to conform to a table value, is it more efficient for performance to use a Every timer Change Attribute with a .2 second loop (all the precision necessary) or a Constrain Attribute? I'm trying to perfect the behavior of my enemy spawn points, and registering the despawning of enemies is the current task. There is likely to be 20-30 spawners per level, each with a copy of whatever i put in here.

Comments

  • hesdeadjimhesdeadjim Member, PRO Posts: 38
    edited May 2014

    I think timers are more expensive... but I'm not sure about that. If I were you, I'd try both in the gs viewer and compare frame rates.

    Another way that might only need one timer is to have a hidden actor in your scene that increases a global int every .2 seconds. Then have all your spawners perform the check whenever the value changes.

    NewHiddenActor: Every 0.2 seconds change checkCount = checkCount+1

    spawner if checkCount (does not equal) selfCheckCount: Do the check, change selfCheckCount to globalCheckCount

    Might be less expensive.

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    A constrain behavior will try to run at 60 times a second. Compare that to a .2 timer which will only update 5 times a second. The slower the timer, (and .2 is very slow in computer time) the less work the processor will need to do.

Sign In or Register to comment.