Jump to content

Pause Physics


gamecreator
 Share

Recommended Posts

I don't know if there is an "official" way to do this... Maybe cycling through all bodies and setting the mass to 0 on pause and then, setting them back to their normal values after pause..... This is just a guess. I have no idea if it will work.

 

Perhaps try this -

On Pause:

1. Record all Velocities & Omegas.

2. Set Velocities & Omegas to 0.

3. Turn off Gravity

 

On UnPause:

1. Set the Velocities, Omegas back to normal.

2. Turn on Gravity

 

Neway it sounds like a messy way to do it but I guess it could work.

 

Dadonik was trying to pause physics recently. Not sure how far he got with it.

STS - Scarlet Thread Studios

AKA: Engineer Ken

 

Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now!

Link to comment
Share on other sites

PauseApp() pauses the application time. Make sure when you are "doing things" whilst "paused" not to update the Apptime.

 

http://www.leadwerks.com/werkspace/topic/2591-how-to-pause-game/page__view__findpost__p__23849

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

I simply use:

// dt = AppSpeed
// time_scale = 0.0 - halt, 0.5 half, 1.0 normal, 2.0 double speed ...
UpdateWorld( dt * time_scale );

.. it does the trick and more, but you are using Framework, so try and replace UpdateFramework() with calls to UpdateWorld (for all 3 world layers) and don't forget to add UpdateAppTime() in there somewhere, but i'm not sure what else UpdateFramework() does, so this might not be an option..

Link to comment
Share on other sites

I wrote my own framework and i managed to pause the physics without any memory leak or other problems.

 

 UpdateAppTime();
   if (m_bIsPaused == true)
   {
    // Update each world with a stepsize of 0 -> paused mode
    LE2LayerPtrMapIt it = m_mapLayers.begin();
    for (; it != m_mapLayers.end(); ++it)
    {
	    if ((*it).second != NULL)
	    {		   
		    (*it).second->SetThisWorld();
		    UpdateWorld(0);
	    }
    }
   }
   else
   {
    // Update each world with a stepsize of AppSpeed -> running
    LE2LayerPtrMapIt it = m_mapLayers.begin();
    for (; it != m_mapLayers.end(); ++it)
    {
	    if ((*it).second != NULL)
	    {		   
		    (*it).second->SetThisWorld();
		    UpdateWorld(AppSpeed());
	    }
    }
   }

 

The "problem" here is that the game is still running and callbacks are still called. So it really just pauses the physics.

(Win7 64bit) && (i7 3770K @ 3,5ghz) && (16gb DDR3 @ 1600mhz) && (Geforce660TI)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...