Detect when a physics object has stopped

Get help using Construct 2

Post » Thu Dec 11, 2014 7:38 pm

Hey folks, trying to determine how to detect when a physics object has stopped moving. I've tried to use the velocity, x velocity, y velocity, but I've noticed that these values are constantly changing in the debugger. Here is my capx, just hit the bottom DICE button and watch. The dice should display their result once they stop moving, only works for some dice.
You do not have the required permissions to view the files attached to this post.
B
4
Posts: 3
Reputation: 206

Post » Thu Dec 11, 2014 8:54 pm

ummm how about you start using stable releases instead? betas always have some bugs (not necessarily physics).

also have you set your gravity to 0 ? if velocity isn't 0 is there a force working on your dices?
Sea Monsters template - Isometric
Also includes 40 pages PDF of optimizations and "how-to" for your games, and how the "sea monsters" template was built. Follow link for details :)

sea-monsters-templates-and-assets_t162705
B
43
S
14
G
12
Posts: 626
Reputation: 9,450

Post » Thu Dec 11, 2014 9:02 pm

Compare velocity
Compare the current velocity (speed) of the physics body, in pixels per second. The velocity can be compared on an individual axis, such as just the X axis to compare the horizontal motion, or the overall velocity can be used.

comparing the velocity to a range of low values could be done, and if you reach said value, you stop the object completely, and that is fine (I think the overall velocity could be used)

I am downloading your capx to see
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Thu Dec 11, 2014 9:25 pm

@squizm

I replaced one of your events, the 5 and 6, it seems to achieve a nice effect!

(see the attachment)

First, the for each was not needed (the conditions already apply the actions for each individual objects due to how the C2 engine works)

Then we check if the objects is not moving too much in term of Y and X velocity, and we also check if the object is not spinning too much (the values are empiric, it just looked good).

I make them unmovable because I do not want them to continue to move just in case..
You do not have the required permissions to view the files attached to this post.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Fri Dec 12, 2014 2:39 pm

Fantastic. This worked. Thank you very much for your help.
B
4
Posts: 3
Reputation: 206


Return to How do I....?

Who is online

Users browsing this forum: boybacteria, dop2000, Microbex, richcoz81, totoe and 37 guests