change position on timer

allc1865allc1865 Member, PRO Posts: 777

I was trying to make my actor go to one position, and then back to the original position randomly on a timer.

I've tried to create it, and it goes up but never comes back down.
You can see what I've done below in the link the my file.

Thanks guys if anyone can help

https://www.dropbox.com/s/8ovj0pt6xnsxfsv/changePositions.zip?dl=0

Best Answer

  • tatiangtatiang Posts: 11,949
    Accepted Answer

    This is sort of a strange setup:

    You're asking your actor to "do something after five seconds every four seconds." Theoretically, it should still run since you have Run to Completion checked but... it's not working so time to come up with a better method.

    What should happen is that at the 4 second mark, the actor should move up and also at the 8 second mark (and every four seconds thereafter. At the 9 second mark (4+5), it should move down (and every 4 seconds thereafter). So if we write out this pattern, we get:

    [0 down]
    4 up
    9 down
    12 up
    13 down
    16 up
    17 down...

    So basically, you're trying to make an actor move up after 4 seconds and down after 1 second... is that correct? If so, change the After 5 seconds timer to After 1 second.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Answers

  • DevirosDeviros Member, PRO Posts: 87
    edited December 2015

    @tatiang @allc1865

    I think it could be even more efficient to use a rule to swap it out, i.e.

    If (self.on == false) {
    ::after 5 seconds, make self.on = true::
    }
    else {
    ::after 1 second, make self.on = false::
    }

    You should end up with a pretty efficient flippy flop.

  • allc1865allc1865 Member, PRO Posts: 777

    @tatiang said:

    So basically, you're trying to make an actor move up after 4 seconds and down after 1 second... is that correct? If so, change the After 5 seconds timer to After 1 second.

    why are you so smart

    thank you :|

    :)

  • allc1865allc1865 Member, PRO Posts: 777

    @Deviros , thank you!

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    @allc1865 said:
    why are you so smart

    thank you :|

    :)

    It's my teachers' fault. You're welcome!

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.