Help! Its Late and can't figure this out

Hello long story short...

I'm making a Astroid/space game in one scene.. Spaceship in the middle and asteroids flying around..

i have a spawner actor that spawns a asteroid in a random(0,360) direction every 1 sec..
On the asteroid for movement, i now use Change Velocity (direction "0" relative to actor, and speed "self.SPEED" self made attribute)

i'm using the "Change velocity" Attribute because, when a asteroid collides with another asteroid, then they can bounce and change direction.. cant do that with "move" attribute nor "accelerate" attribute I THINK?..

Now comes the hard part for me.. when i pause the game, i dont use the "pausegame" attribute, and that is not gonna change.

what i want is when i press my pause button (changes my boolean called game.GAMEPAUSE to true) is to freeze the asteroids until game.GAMEPAUSE is false)

(when using MOVE attribute on asteroid, i could just do this.. MOVE attribute - direction"0", speed"self.SPEED".. and just make a rule that if game.PAUSE is true change self.SPEED to "0" otherwise change self.SPEED to "50") but then i lose the cool bounce, and change direction feature that Change Velocity has! NO WAY to COOL!

i've tried using a rule called.. If game.PAUSE is true, then change self.Physics.Movable to "false" otherwise "true".) that didnt work :,(

i've tried using a rule called.. If game.PAUSE is true, then change self.Motion.MaxSpeed to "0" otherwise change self.Motion.MaxSpeed to "50".) that didnt work :,( they did stop. but they stopped for good! :,(

then tried a rule called.. If game.PAUSE is true "change velocity" attribute direction"0" speed"0" otherwise "change velocity" attribute direction"0" speed"50".. But then if the astroid has hit another asteroid, and changed direction. Before i PAUSE the game, then when i UNPAUSE my game, the astroid changes direction to the original direction.. plus i cant use "rotate" attribute then it just goes wild!!

I hope someone have a SUPER EASY "I SHOULD HAVE THOUGHT OF THAT" solution!

Can't wait to hear from some of the GURU's in here :D

Comments

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    One way would be to pre-calculate the actor's "direction" and "speed" and store them attributes. You would use these attributes in a change velocity behavior to set the actor on its proper path. Then when you pause the game, the values are already stored. And when you unpause the game -- you just put the saved "self.direction" and "self.speed" attributes into a new change velocity behavior.

    --------------------
    A second way to do it is to save the "direction" and "speed" values just before you change the velocity to 0. Then when the game is unpaused, you do another change velocity behavior (and put in the saved "direction" and "speed" into their proper places).

    You can find an actors "direction" with a vectorToAngle function:
    Change Attribute: self.currentDirection To: vectorToAngle( self.Motion.Linear Velocity.X , self.Motion.Linear Velocity.Y )

    You can find an actor's "speed" with a magnitude function:
    Change Attribute: self.currentSpeed To: magnitude( self.Motion.Linear Velocity.X , self.Motion.Linear Velocity.Y )


    Here is a demo showing the second method.
  • luckyleafluckyleaf Member Posts: 7
    One way would be to pre-calculate the actor's "direction" and "speed" and store them attributes. You would use these attributes in a change velocity behavior to set the actor on its proper path. Then when you pause the game, the values are already stored. And when you unpause the game -- you just put the saved "self.direction" and "self.speed" attributes into a new change velocity behavior.

    --------------------
    A second way to do it is to save the "direction" and "speed" values just before you change the velocity to 0. Then when the game is unpaused, you do another change velocity behavior (and put in the saved "direction" and "speed" into their proper places).

    You can find an actors "direction" with a vectorToAngle function:
    Change Attribute: self.currentDirection To: vectorToAngle( self.Motion.Linear Velocity.X , self.Motion.Linear Velocity.Y )

    You can find an actor's "speed" with a magnitude function:
    Change Attribute: self.currentSpeed To: magnitude( self.Motion.Linear Velocity.X , self.Motion.Linear Velocity.Y )


    Here is a demo showing the second method.
    WOW that second way worked almost perfectly THANKS!
    the only problem i had was when i activated game.GAME (for activating game)

    The self.OLDSPEED and self.OLDDIRECTION would be "0" so the asteroid would'nt move at all.

    But this was not a big deal, just did this..

    Make a boolean on asteroid called "hasBeenPaused"

    Then if game.PAUSE is true:

    change self.OLDSPEED to "magnitude( self.Motion.Linear Velocity.X , self.Motion.Linear Velocity.Y )"

    change self.OLDDIRECTION to "vectorToAngle( self.Motion.Linear Velocity.X , self.Motion.Linear Velocity.Y )"

    change velocity to "direction to 0 and speed to 0"

    change self.hasBeenPaused to "true"

    THEN

    Otherwise - new rule

    if attribute hasBeenPaused is "TRUE"

    change velocity
    Direction to self.OLDDIRECTION
    speed to self.OLDSPEED


    DONE!!!

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    Great thinking!
    Glad it's working for you.
Sign In or Register to comment.