Game State Help Please

micksolomicksolo Member Posts: 264
edited November -1 in Working with GS (Mac)
Hi everyone, merry xmas and happy holidays to you all!

I'm running into some problems getting states working right.

It should be simple right?

I have an game attribute integer set to 1. press space bar and it should change to 2. Press space bar and it should change back to 1.

However when I run the game, press space bar the integer does not change from 1. I know this because I displayed the game integer on screen.

Here's what I set in the player actor.

http://img692.imageshack.us/img692/8881/gamestateprob.png]

Funny thing is when i change the key for game state 2 to something else, it actually works. So it seems the problem is that it doesn't differentiate between using the same key.

Any help?

Thanks!

Comments

  • MotherHooseMotherHoose Member Posts: 2,456
    @micksolo

    use one rule to enclose both action

    [Rule]
    when spacebar is down
    --[Rule] when game.Rotation = 2
    ----change game.Rotation To: 1
    --Otherwise:
    ---[Rule] when game.Rotation = 1
    -----change game.Rotation To: 2

    that may help...
    also if you only have the 2 states you should use a boolean type gameAttribute
    unchecked/false for state1 and true for state2

    MH
  • micksolomicksolo Member Posts: 264
    thanks a lot MotherHoose. That nearly worked! I had to add a 3rd otherwise in and it nearly works. only problem is that i have to hold down space to keep it in state 2 otherwise it just goes back to state 1.

    Basically i want this to happen

    game starts = state 1
    press space bar = state 2
    press space bar = state 1
    and so forth

    right now i have to hold down space for it to stay in state 2.
  • MotherHooseMotherHoose Member Posts: 2,456
    mick... I tried this and it worked for me... it maintained the state until spacebar was again pressed.

    pix

    "state" is boolean

    MH
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Easier and probably more reliable way is to do this:

    When key 'space' is pressed:
    Change Attribute: game.Rotation = game.Rotation%2+1
  • micksolomicksolo Member Posts: 264
    yep that works! sorry I made a mistake the first time around. Thank you very MotherHoose and have a great holiday season!
Sign In or Register to comment.