playMaker

Author Topic: [SOLVED] Check if Physics is still active?  (Read 2486 times)

jasta07

  • Playmaker Newbie
  • *
  • Posts: 2
[SOLVED] Check if Physics is still active?
« on: May 20, 2012, 12:40:40 AM »
I've got a game which is sort of turn based, but uses real time physics. I want the player to do an action which kicks off a bunch of objects bouncing around etc. and then be able to take their next turn once everything has stopped moving (think of it like pool/billiards).

I've tried creating a loop which in theory checks the children of a particular object (which holds all the moveable objects) and if they are still moving it keeps checking until they're all stationary/sleeping and then updates the game accordingly but everything I've tried doesn't seem to work for some reason. My loop either finishes long before everything has stopped moving, or it gets stuck in weird states that don't make sense (there's no reason for the FSM to pause at a state that just compares an int and has all three options with events leading out of it... is there? Do I have to reset it somehow?)

I've tried checking each object for isSleeping/isKinematic, is their speed > 0 etc.

I've tried making a global bool false, running the loop to check if each object is moving and if it is, setting the bool to true, checking the bool again and if it's true starting the whole loop again etc.

I think I'm screwing up fundamentally somewhere... pretty new to Playmaker. Any one got a sample I can look at?
« Last Edit: May 20, 2012, 03:25:23 AM by jasta07 »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4000
  • Official Playmaker Support
    • LinkedIn
Re: Check if Physics is still active?
« Reply #1 on: May 20, 2012, 02:32:42 AM »
You may be creating an infinite loop, never allowing the next update to happen. When you test if the bool is true, transition to a state that waits a little before checking again (e.g., Send Event with a delay, or a Next Frame Event if you want to check every frame).

jasta07

  • Playmaker Newbie
  • *
  • Posts: 2
Re: Check if Physics is still active?
« Reply #2 on: May 20, 2012, 03:24:42 AM »
Awesome! A little wait after updating the bool fixed it, thanks Alex!