how can i Change actor's speed every 10 seconds

diegocsdiegocs Member Posts: 531
edited November -1 in Working with GS (Mac)
i want my actor to increase speed (for example x+25) every 10 seconds, also take in fact that my actor bounces against the borders of the scene, can someone tell me how to do this

Comments

  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    First if you want every 10 seconds, use the Timer behavior.

    Next it depends on how you are moving your actor.
    If you are not using the Move behavior or the Move To behavior you can do this.

    Inside the Timer behavior, use
    Change Attribute: self.Motion.Linear Velocity.X to
    self.Motion.Linear Velocity.X +25*cos(vectorToAngle( self.Motion.Linear Velocity.X , self.Motion.Linear Velocity.Y ))

    and

    Change Attribute: self.Motion.Linear Velocity.Y to
    self.Motion.Linear Velocity.Y +25*sin(vectorToAngle( self.Motion.Linear Velocity.X , self.Motion.Linear Velocity.Y ))

    Remember to select the attributes from the attribute browser instead of just typing the above in.

    Why this works:
    the vectorToAngle parts of the expressions give you the angle of the current velocity.
    The sin/cos around that angle will give you the number to multiply your increasing value(25) to add to the current Linear X and Y values so that the speed is increased by 25 in the same direction as it is currently going in.
  • design219design219 Member Posts: 2,273
    Wow.
  • Rob2Rob2 Member Posts: 2,402
    Amazing isn't it......
  • ToastKittenToastKitten Member Posts: 360
    Darn it!

    You stole one of the more math heavy examples CodeMonkey!!
  • diegocsdiegocs Member Posts: 531
    hey thanks man really helpful now i can continue with my game, it was a problem i had been stuck with for a while
  • EastboundEastbound Member, BASIC Posts: 1,074
    Why wouldn't he just set a timer and say every 10 seconds:

    Change Velocity behavior: Speed = speed +25

    I don't see the need for the math here...
  • diegocsdiegocs Member Posts: 531
    yeah it doesn't work, already tried
  • 8BitMichael8BitMichael Member, PRO Posts: 125
    Lol, they're acting like they're involved for all the eyes that are on this forum now.
  • ToastKittenToastKitten Member Posts: 360
    http://gamesalad.com/forums/topic.php?id=11782

    Have been trying to help since before the commotion :P
  • EastboundEastbound Member, BASIC Posts: 1,074
    ToastKitten said:
    http://gamesalad.com/forums/topic.php?id=11782

    Have been trying to help since before the commotion :P

    I think he meant GS staff, not any of the members.
  • ToastKittenToastKitten Member Posts: 360
    Eastbound said:
    I think he meant GS staff, not any of the members.

  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Eastbound said:
    Why wouldn't he just set a timer and say every 10 seconds:

    Change Velocity behavior: Speed = speed +25

    I don't see the need for the math here...

    Because math is fun. But you could use Change Velocity.

    Angle would be: vectorToAngle( self.Motion.Linear Velocity.X , self.Motion.Linear Velocity.Y )
    Speed would be: magnitude( self.Motion.Linear Velocity.X , self.Motion.Linear Velocity.Y )+25
    Relative to Scene
  • ChaserChaser Member Posts: 1,453
    Try as you may to save gamesalads rep but the damage is done
Sign In or Register to comment.