Timer vs self.timer Question.

CaptFinnCaptFinn Member Posts: 1,828

Instead of using a timer. I felt it was better to use a actors self.time. Easier on internal number crunching and processing.

But I got to wondering.........is it?

Example:

Project 1. Blank Project with 1 default white square actor in the center of the screen.

Project 2. Blank Project with 1 default white square actor in the center of the screen. But now this actor has been told to move to a x/y position if self.time is equal or greater than 10.

My question is this. Does a actors self.time run in the background, wether it has a rule in regards to its self.time. Or "only" when it has a rule in regards to its self.time.

Is it setting there bored.......... then all of a sudden it goes "oh !@#$%!!....something needs my self.time. I better start counting."?

If thats the case then I can see how its easier on the system. But if not.. how is it better than a timer?

I ask this in regards to timers vs self.time.

Comments

  • CaptFinnCaptFinn Member Posts: 1,828

    yes i read it. But im curious in these examples. Does a actor count when its not asked to ahead of time? Or does the rule look over to the actor and see where the actor is in its counting?

  • tintrantintran Member Posts: 453

    My guess is it probably start counting as soon as the actor is created.
    But I think maybe only the GS developer can answer that for sure as it is behind the scene and not testable.

  • MentalDonkeyGamesMentalDonkeyGames Member Posts: 1,276
    edited July 2015

    The self.time starts counting instantly.
    Any rules you make in the actor does not affect that, and you can´t reset or modify self.time. It keeps counting until you destroy the actor.

    The same goes for game.time. You can not reset or modify it. It starts counting instantly when the app is launched, and will keep counting till you exit the app.

    Mental Donkey Games
    Website - Facebook - Twitter

  • birdboybirdboy Member Posts: 284
    edited July 2015

    All time attributes run automatically, no matter what rules you put up. But something to keep in mind is that an actor's time attribute resets to 0 every time you enter a scene (by changing or resetting the scene) and pauses if you pause the scene. The game.time attribute keeps running throughout the whole game (even pause scenes), only tabbing out of the game pauses it.

  • CaptFinnCaptFinn Member Posts: 1,828

    Nice to know. But using a actors time is more efficient than adding a timer inside the actor?

    Is there a way to make a rule Every time self.time is a multiple of 10. Do something?

  • MentalDonkeyGamesMentalDonkeyGames Member Posts: 1,276

    @FINNBOGG said:
    Nice to know. But using a actors time is more efficient than adding a timer inside the actor?

    Is there a way to make a rule Every time self.time is a multiple of 10. Do something?

    Here is a demo.
    It´s every 5 seconds, but you can change it to anything you want.

    Mental Donkey Games
    Website - Facebook - Twitter

  • birdboybirdboy Member Posts: 284
    edited July 2015

    Yes, it is more efficient. I don't know by how much exactly.

    I don't have time to check it right now but something like this should work the same way an 'every'-timer does:

    if (mod(floor(self.time),10) = 9

    do stuff

    If you want something every two seconds you would use

    if (mod(floor(self.time),2) = 1

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    @FINNBOGG said:
    Nice to know. But using a actors time is more efficient than adding a timer inside the actor?

    Is there a way to make a rule Every time self.time is a multiple of 10. Do something?

    That used to be the case but not so much anymore. Those tests were done years ago. I used to use it all the time but as GS got better i went back to using timers for 95% of things. Basically i only use self time when i want to sync multiple things when i need tenths of a second accuracy like display text in sync with audio.

Sign In or Register to comment.