Distance Measured with Arrow Keys

0 favourites
  • 4 posts
From the Asset Store
Full game Construct 2 and Construct 3 to post on Google Play
  • Hi all, so I am learning the basics of movement and measure. I have a box just moving down and up from the roof to the floor. I have a (every tick) text set to display the distance from origin (the roof, a solid impassable object) I have the keyboard function when key pressed down (arrow key) add 1 to global distance. When I play the game, the box moves down from the roof and this number takes off fast, so I changed it to add 0.01 (global) instead of 1 which makes it more realistic. So say the box moves down 10 in distance hits the floor (another impassable object) But my trouble is the numbers continue when the box collides with the floor or roof. I have subtract 0.01 for moving back up. Is there a way to set a threshold for numbers so when they reach say 0 or 10 they will stop counting even if the up or down key is pressed. In a nutshell imagine a box moving down from the roof starting at 0 hits the floor at 10 then moves back up to the roof at 0 with these numbers in the HUD. Thank you in advance! One more thing, lol, can you make the count slower or do I have to stick with the 0.01. Thanks again for all your guys help!

  • Hey Trailbike,

    It sounds like you want to compare the variable changing the speed. If your condition is "When key down add to speed", you just have to add another condition that makes sure the speed (or number) isn't over the amount you want it to go over.

    Here is an example.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • you can add when if keyisdown and number is less or equal to some number add 1 to the number if its not equal or less just do the oposit, and should automatically stop adding numbers if u have a capx example to share we can understand better what u need to do, i think its just a matter of conditions u need to setup, cause as u said it doesnt stop when u are on top or bottom of roof, so that means u dident told the system to stop if the number is at end (therefore u need to know the length of the roof u travel)

  • Thanks GenkiGenga and gamecorpstudio. gamecorpstudio, yes I did this like you said and also added when I have the box collide with the roof this event will reset the global variable keeping it at 0 and set the greater then for the floor. This is what I got and it works pretty good! Thanks again, you guys rock. GenkiGenga, now I will work on the speed variable and make some fine adjustments. I have shared the file with you of my progress.

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