A condition that says object has stopped moving

Get help using Construct 2

Post » Mon Sep 26, 2016 2:18 pm

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".
Life is like a game, with permadeath.
Posts: 10
Reputation: 1,114

Post » Tue Sep 27, 2016 4:08 am

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.
Posts: 391
Reputation: 7,845

Post » Tue Sep 27, 2016 4:13 am

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.
Posts: 97
Reputation: 6,584

Post » Tue Sep 27, 2016 1:30 pm

If you move it by physis, physics has a 'is sleeping' condition.
Else you got to elaborate about how you move it.
Posts: 2,493
Reputation: 20,950

Post » Tue Sep 27, 2016 7:50 pm

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
Posts: 5,291
Reputation: 70,993

Return to How do I....?

Who is online

Users browsing this forum: beohs, Blendi1223, Elliott, MadSpy and 11 guests