Calculating if nodes are moving

Hi I am currently making a pool game and I want to define the end of a shot as when all the pool balls have stopped moving. Each ball has its own dynamic physics node. I know that I can do getLocalTranslation() or getWorldTranslation() every so often for each ball and check them individually to see if they are moving. I was just wondering if someone knew a more efficient way to check if any nodes attached to the rootNode are moving.



Thanks

Well I have never played with physics yet, so I do not know anything about that… but from the general imagination-land… how about:



When you do a hit, the affected ball (or its id) is added to a list. When it collides with another ball, the new ball is also added to the list etc.



I do not know if you can add some method or listened or condition to your physics node (this is the part about me knowing jack about physics), that removes the ball (or it's id) from the 'ball-list' when the speed falls to 0. In this case, whenever you just ask the size of this list, you will know how many balls are still in motion.



Depends on one being able to do in physics what I described though :slight_smile:

read the velocity of the balls? or if you configured auto-disabling: check enabled state

Is there a way to read the velocity of the balls? if there is that would be very helpful.

sure: getLinearVelocity() and getAngularVelocity() :slight_smile:

thanks

I was wondering Irrisor if its not already on the wiki did u want me to add about velocity??

me220 said:

did u want me to add about velocity??

sure :)  (there "force", "torque" etc. on the main page - velocity would fit fine there)

I was just playing around with the velocity's but it keeps returning null. I guess I'm invoking them incorrectly. I have cueBall.getLinearVelocity(cueBallVelocity) and then I print out cueBallVelocity but it returns null.

Don't worry i've got it to work now.