Physics and python sleeping

well im making a physics game and it has dominoes in it, but they dont fall asleep when i want them to. so what i want to know is how i could create a simple python script that would put all of the objects to sleep after the last domino fell and hit an object. unfortunately i know almost no python, so i need a lot of help:o

im thinking it should be easy to do: just have a logic brick sense the desired collision, and link to a script that puts to sleep a list of objects i give it.

help would be greatly appreciated!

Following script pauses all physics. It works in Blender 2.42a.

import PhysicsConstraints
PhysicsConstraints.setNumTimeSubSteps(0)

thanks, but i was looking for something that only paused the physics (put to sleep) only a list of objects that i would specify. otherwise all of the rest of my game would stop working!

Run owner.suspendDynamics() on every object you want to stop moving. ‘No sleeping’ has to be unchecked.

how do i get that to work? i tried this:

import PhysicsConstraints
owner.suspendDynamics(Sphere.008)

im probably way off

what should i do that im not doing or doing incorrectly?

this is it
just copy this onto the objects you want to stop
though you will need to set something when to activate it

 
owner = GameLogic.getCurrentController().getOwner()
owner.suspendDynamics() 

Thank You!! it works!!

now i can reduce my physics overhead rubs hand in anticipation of higher fps

on second thought, how would i get something that is sleeping to wakeup during the game? this would enable me to further decrease my overhead by only having the parts of the game that i want be active oh and since i have allready proven i don’t know python could you please write the script as though it was standalone, like littlebob did?

it would be a great help and i would greatly appreciate it!

Just make a copy of the Littlebob’s script and replace suspendDynamics() with resumeDynamics()

thanks allot! its a big help, and hopfully this will help with my low fps cause this game has ALOT of physics enabled pieces

i mean its probable pushin atleast 60 lol

1 Like

hi, can i stop dynamic like suspend.Dynamics(), but not this object which is doing the script? I mean if i can say in any script the names of objects and they will stop. I want to stop many objects, so if i put logic to each one object, it would slow the game, so I want to give a list of objects and stop them in one script :slight_smile:

yea now that i think about that id like that to, lukasz2121

could any one write a script to do that?
if it could be done it be awsome

1 Like