Using self.time - advantages over timer behaviours

AfterBurnettAfterBurnett Member Posts: 3,474
edited November -1 in Working with GS (Mac)
Hi guys,

Are there any advantages from using self.time over the timer behaviours? I've read that timers can kill the CPU... is this the same with manipulating an actor's self.time?

Comments

  • synthesissynthesis Member Posts: 1,693
    Yes...using the actor or game timers can be quite advantageous in optimization of your game.

    Here is an old tip on the subject I wrote:
    http://www.gsproforum.com/viewtopic.php?f=18&t=2
  • AfterBurnettAfterBurnett Member Posts: 3,474
    Awesome, thanks!
  • reddotincreddotinc Member Posts: 653
    Thanks synthesis!

    How would you implement that for every X seconds?
  • synthesissynthesis Member Posts: 1,693
    @reddot
    An every X is more complex...

    I haven't done it...yet...but I imagine its possible.

    One thought is...
    When actor is spawned (or triggered):
    setTime = TRUE

    When setTime = TRUE
    markTime = self.time
    repeatMarkTime = markTime + 5 (or however many seconds you want for the loop)
    setTime = FALSE (shutoff)

    LOOP RULE:
    when self.time > repeatMarkTime
    [ insert rule sequence here for the loop function ]

    the last behavior in the loop would be setTime=TRUE
    (this would trigger the time marks to update and the loop would then wait for the next loop condition to become valid)

    Its not proven (by me)...but seems like it would work theoretically.
    I'm also not sure if it would be PERFECT in time execution or if it would work on VERY FAST loops...but on slow loops (over say 3 seconds) I would think it would work well...so long as the loop routine's lifespan doesn't exceed the loop amount (such as interpolations).

    Mess around with it and you might find the sweet spot.
  • scorelessmusicscorelessmusic Member Posts: 565
    Cool implementation, synthesis! I will remember to try something like this in the future. :)
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    is there anyway to use modulus to do an "every" type timer with self.time
  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    Change self.loop(integer) to 5

    Rule:
    When self.loop = ((floor(self.time)-1)%5)+1
Sign In or Register to comment.