Re: How do I Toggle a VAR on and off? (SOLVED)

0 favourites
  • 7 posts
From the Asset Store
Toggles Dials Switches and Alerts ! A foundational sound grouping of Analog type switches and Steampunk effects
  • Ok, this should be simple but I've tried everything I know and I can't get it to work. I'm making an Infinite driving game with my Son (Up and down on the Y) and I want to add a gear shift to the car. So the car is controlled with the arrow keys (up,down,left,right on set to angle, not 8 behavior) I have a VAR called gears and when the up arrow is pressed it adds 1 to the Var and when the down arrow is pressed it subtracts 1. So you start in 1st gear and you can go up to 5 gears each one speeding up or slowing down the speed on the BGRoad Var.

    Now what I want to happen is when the Gear Var gets to 5 it stops at that speed level even if you hit the up arrow again it doesn't say 6 or 7 and when it's in 1st gear it stops there. not -1, -2 and so on. The text is set to the VAR so one should fix the other...

    Thank you in advance and I hope I explained it properly.

    Thanks

  • On Up Pressed - Set GearVar to min(5,GearVar+1)

    On Down Pressed - Set GearVar to max(0,GearVar-1)

  • Thank you I'll let you know. I do appreciate the help.

  • oosyrag

    I appreciate the help but maybe I'm not following or explaining it correctly so maybe this will help.

    I need it to stop at 5 (5th Gear) even if you keep left-clicking and stop at 0 (Stop Game) even if you keep right-clicking...

    How do I tell the GearsVar not to keep adding or subtracting once it reaches a certain number even if the button is clicked again?

    Thank you

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Remove the the add and subtract actions, and then remove the conditions that compare the gear variable. It should look like what he typed above.

  • R0J0hound and oosyrag Thank you both for the help I was coming to mark this solved because what I did was just change the condition from if=5 to if=6 and from if=1 to if= -1 and it seems to work. Now R0J0 if you feel your way is better I will try that so there are no hiccups down the road...

    let me know please

    Thank you my friends...

    After thought, OK I get it! Remove mine and add yours not both correct? Duhhhh OK thanks.

  • THAT WAS IT!!!! Thank You Very Much...

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)