Physics Behaviour

Get help using Construct 2

Post » Tue Jan 29, 2013 9:37 pm

Dear All,

I am just stuck in achieving a simple thing, and desperately looking for help.

Well i have a sprite and have applied physics to it. Well its a ball and it fires at the angle where the mouse is pointed on mouse click.

Now what i want to achieve is, when the ball(which has physics behaviour applied) and i move it using impulse towards angle,

well i want when the ball stops moving i want the game to over and apply like try again or anything, but i cant get the coding sorted what needs to be done.

B
5
Posts: 13
Reputation: 401

Post » Tue Jan 29, 2013 10:38 pm

Try this:

If
System -> Sprite.Physics.VelocityX = 0
and
System -> Sprite.Physics.VelocityY = 0
Then
End Of Game
B
13
S
4
G
3
Posts: 75
Reputation: 3,425

Post » Tue Jan 29, 2013 10:44 pm

ok Dear RangerJim, this sounds understandable, but the thing is on start of layout the ball is already static, and moves only on mouse click, so when then game will start, the velocity 0 condition will match and it it will end the game on start of layout.....
B
5
Posts: 13
Reputation: 401

Post » Tue Jan 29, 2013 10:44 pm

you could check to see if the object Is sleeping (physics property)
B
44
S
15
G
9
Posts: 1,096
Reputation: 11,013

Post » Tue Jan 29, 2013 10:50 pm

Make a new variable. If the velocity goes above 0, set this variable to 1. If the new variable is 1 and the velocity is 0, you know it has moved and stopped.
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Tue Jan 29, 2013 10:51 pm

@Spongehammer, again i tried that, but as i have mentioned, the object on start of layout is already static/sleeping and only moves on mouse click... so it doesnt helps...

i have also tried to make 2 conditions meet like if physics is sleeping and object is overlapping the base/ground even then it doesnt works....

B
5
Posts: 13
Reputation: 401

Post » Tue Jan 29, 2013 10:58 pm

Nimtrix's solution is what I was going to write after I read the first post, but obviously he got there first ;)
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Post » Wed Jan 30, 2013 12:02 am

@Nimtrix and Procrastinator i already tried that, it doesnt work either...
B
5
Posts: 13
Reputation: 401

Post » Wed Jan 30, 2013 12:16 am

Ah ok then it must be to do with real numbers. Physics velocity could be at 0.01, which is still > 0 , so it won't stop.

Try what Nimtrix suggested, but..

If floor(velocity) > 0 then hasStopped = false
else
hasStopped = true
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Post » Wed Jan 30, 2013 9:04 pm

@procrastinator dude didnt work out... with the nimtrix suggestion... and ur last suggestion i couldnt quite make sense of it... am still a kid with this software...
B
5
Posts: 13
Reputation: 401

Next

Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 28 guests