switch help

poopdecksweeperpoopdecksweeper Member Posts: 180
edited April 2012 in Working with GS (Mac)
I have a switch that turns on the light whenever my actor overlaps it, but the problem is that the switch toggles between on and off every single second my actor is overlapping. I need to make a few boolean and integer attributes to stop the automatic switching on and off of the switch to: actor hits switch then only after 3 seconds can the actor hit it again.

thanks

Best Answer

  • UtopianGamesUtopianGames Posts: 5,692
    Accepted Answer
    Make a boolean called SwitchActive leave it set to false then when your player hits the switch change it to true. Have a rule with a timer inside..something like if game.SwitchActive=true after 3 seconds change attribute game.SwitchActive to false.

    Darren.

Answers

  • poopdecksweeperpoopdecksweeper Member Posts: 180
    Thanks Darren I'll try it. It's funny I'm actually over at DBA right now looking at assets.
  • poopdecksweeperpoopdecksweeper Member Posts: 180
    What @UtopianGames said isn't working. I have two attributes: (isLit) - Boolean & (Transition) - real. This is what I have:


    When main actor overlaps switch actor,
    and transition = 3

    then after .01 (RTC)
    change attribute Transition to 2
    ___________________________________

    When main actor overlaps switch actor,
    and transition = 2

    For 2 seconds (RTC)
    every 1 second Change attribute to transition to transition-1
    ___________________________________

    When transition = 1,
    change attribute (transition) to 3,
    ___________________________________

    When main actor overlaps switch actor,
    and Transition is greater than 2.9,
    and isLit is false

    Then change attribute isLit to True
    ___________________________________

    When main actor overlaps switch actor,
    and Transition is greater than 2.9,
    and isLit is true

    Then change attribute isLit to false



    Grrrrrr....what should I do?
  • poopdecksweeperpoopdecksweeper Member Posts: 180
    bump
  • poopdecksweeperpoopdecksweeper Member Posts: 180
    Bumps
  • mynameisacemynameisace Hull, UKMember Posts: 2,484
    I'm fitting a new bathroom in my house at the moment but made this for you on my break:

    http://www.mynameisace.com/switch.gameproj.zip

    Ace
  • poopdecksweeperpoopdecksweeper Member Posts: 180
    Hey Ace, thanks for that, I appreciate your valiant effort (even during your arduous bathroom renovation and all), but I need to have the light switch stay on after the actor has stopped touching the switch. Then, once the actor comes back and touches the switch again, I would like it to turn off.

    Thanks for the help
  • mynameisacemynameisace Hull, UKMember Posts: 2,484
    I can't remember how I set up the code, but delete the change attribute for the overlap/collide and the otherwise and just have when actor overlaps or collides with switch change attribute game.switch to (game.switch+1)%2

    I'm on my phone so can't test it in the project but just try that in my example.

    Ace
  • mynameisacemynameisace Hull, UKMember Posts: 2,484
    Finished for the day (I have no bath/shower and my bathroom looks like a bomb hit it). I've seen more pipes than Mario, but here's the updated file:

    http://www.mynameisace.com/switchcollide.gameproj.zip

    Ace
  • poopdecksweeperpoopdecksweeper Member Posts: 180
    Hey Ace thanks, once I get home i'll try it out.
  • mynameisacemynameisace Hull, UKMember Posts: 2,484
    Okay. Let mw know if it works out for you!

    Ace
  • poopdecksweeperpoopdecksweeper Member Posts: 180
    Dude! Thanks a million! I have been waiting to go further with one of my projects because of that, and now it's fixed!!

    If you ever need help with anything or some art then let me know.
Sign In or Register to comment.