A condition that says object has stopped moving

0 favourites
  • 5 posts
From the Asset Store
112 High-Quality destruction sounds for videogames
  • I want to know how to make a condition that says object has stopped moving.

    I work on a project there gamers goal is to get a object (in this case the player-object) to get to the ground, but if its bounce out the screen or fall into a hole, you will lose.

    So far so good, the game sense if the object left the screens borders, and restart. But if it land on the ground the gamer win and can contiue to next level.

    The problem I got if if it bounce to the ground and then out of border, it counts for winning, therefore I set a wait-timer, but then the win-screens appear but you still lose.

    I want to set a condition for winning that says to the game; "the object is not moving, lemme win if the condition for touching the ground is true".

  • I know this seem a bit silly but have you tried something like add in behavior movement and set its input to ignore and then use if object behavior is not moving ? as in not = invert ?

    then instead of wait condition you could use timer instead such as if landed on ground start timer of 3 sec

    if it is moving stop timer.

    and once 3 sec of timer is up you win ?

    Btw the Wait condtion only does Wait for condition so that other even can run and when the time is up the wait will allow the rest to go through regaurdless if it met or not the condtional requirement.

    So Timer is your best bet if you want something like what you are asking.

    if you need help just take a look at the timer manual.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Maybe you can add a global text variable and set it to "FALSE" at the start of each level

    at Start of Layout -> set variable WIN to "FALSE"

    if Player bounces of ground -> set Win to "TRUE"

    if (any lose conditions) and WIN equals "FALSE" -> lose

    This way the losing events will only trigger if the player has not won the level yet.

  • If you move it by physis, physics has a 'is sleeping' condition.

    Else you got to elaborate about how you move it.

  • You could check if the object's speed is zero. Most behaviors have some way to compare speed, alternatively you could save the object's position to some variables every tick and then right above that event check to see if the current position is different than the current. Probably you'll want small changes to count as not moving. Here's an example permitting anything less than 1 pixel as not moving.

    global number oldx=0

    global number oldy=0

    system compare abs(oldx-sprite.x) < 1

    system compare abs(oldy-sprite.y) < 1

    --- do something since the sprite isn't moving

    every tick

    --- set oldx to sprite.x

    --- set oldy to sprite.y

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