How do I pause physics for an object

Get help using Construct 2

Post » Tue Feb 28, 2012 3:31 pm

Hi,

Sorry, total nube to the physics stuff...
I have a sprite set to have physics...works great...

But I want to pause its physics and restart them..how do I do this?

thanks
B
45
S
8
G
4
Posts: 414
Reputation: 6,805

Post » Tue Feb 28, 2012 3:47 pm

What do you mean "pause and restart" physics ?
Maybe you could post an example capx, or screenshots.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Tue Feb 28, 2012 3:57 pm

if ths falling, stop falling, if its rotating, stop rotating, if its going upward, stop going upward, etc.

I want to ...on event>>> pause any physics applied to a sprite
and on another event>>>restart the physics

make sense?

this could be used to pause a game to allow a custom menu system,or to pause and unpause specific objects.
B
45
S
8
G
4
Posts: 414
Reputation: 6,805

Post » Tue Feb 28, 2012 5:53 pm

Then in that case, on pause you need to store the values
object.physics.VelocityX
object.physics.VelocityY
object.physics.AngularVelocity
and set those to 0
Also set immovable to "Immovable"

On unpause, you set them to the value you stored and set immovable to "Movable".
VelocityX/y are the "vector" speed (translation of the object) and AngularVelocity is the rotation speed.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Tue Feb 28, 2012 7:21 pm

Thanks for the help Kyatric...I'll give that a try.
B
45
S
8
G
4
Posts: 414
Reputation: 6,805

Post » Thu May 17, 2012 7:23 pm

Well with physic it's pretty simple according this tutorial :
http://www.scirra.com/tutorials/67/delta-time-and-framerate-independence/page-1

Set time scale of game to 0 to pause the game and 1 to unpause... enjoy
B
12
S
2
G
3
Posts: 15
Reputation: 2,515


Return to How do I....?

Who is online

Users browsing this forum: austinblackbelt and 35 guests