increase speed after x seconds

Hello again,
so basically for 10 seconds I have actors moving down the screen (270 degrees) and they are at a speed of 150. What I am trying to do is increase the speed up to 200 after 10 seconds. how can I do this?

Comments

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

    Use a timer to determine when 10 seconds have passed. Make sure that your speed value is an attribute rather than a constant. Within the timer behavior, change the speed attribute to 200.

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

  • Simple Gamer ArtsSimple Gamer Arts Member, PRO Posts: 305

    In the actor that is moving down:
    • Create a self integer attribute: self.velocityY
    • Create a self integer attribute: self.timerspeedchange and set it to 10
    • Create a self integer attribute: self.speedY and set it to -150

    Create RULE inside that same actor:
    When velocity Y is < 0 ,
    •Then put a timer behaviour inside that rule:
    ••every 1 second:
    put a "change attribute" behaviour in that "timer" behaviour:
    • self.timerspeedchange to self.timerspeedchange-1

    Create another RULE inside that same actor:
    When self.timerspeedchange = 0:
    put a "change attribute:"
    • self.speedY to - 200

    Of course, you must use the motion attribute: self.velocity to command the speed of the actor... this is why you must use -150.

  • jessica.michaeljessica.michael Member, PRO Posts: 27


    I tried doing that and it didn't work so I must've put in the code wrong

  • jessica.michaeljessica.michael Member, PRO Posts: 27

    Its okay now, I got the change of speed working thank you!!

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

    Glad you got it working. Another way to think of this is to understand that the Move behavior constantly checks the speed value. So you can also do it this way:

    Move [direction: 270] [speed: game.speed]

    Timer
         After 10 seconds
              Change attribute game.speed to game.speed+50

    That way, if you have other changes you want to make to the speed, you only need a single Move behavior.

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

Sign In or Register to comment.