Detect when all actors have stopped moving

monkeedmonkeed Member Posts: 22
edited May 2012 in Working with GS (Mac)
How do I determine when all actors in a scene have stopped moving?

Best Answers

Answers

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    In each actor, you'll need to check to see if self.motion.linear velocity.x=0 AND self.motion.linear velocity.y=0. How you actually count them all (a game-level integer or boolean attribute), I'm not sure about. I would try it with a boolean and see how it works.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • monkeedmonkeed Member Posts: 22
    OK, I'm trying to work this out. I have set up a game level integer attribute. I have 3 actors and I'm trying to get this attribute to be 0 if all actors have stopped.

    So if self.motion.linear.x or self.motion.linear.y are > 0 add 1 otherwise subtract 1.

    I can't get this to do exactly what I'm attempting. The attribute ends up 0 if all actors are moving and -3 if all 3 have stopped. Any ideas?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited May 2012

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • monkeedmonkeed Member Posts: 22
    Thank you very much, it's getting very close. It works great if all my actors are moving at the start of the scene.

    But sometimes my actors start stationary and then move. In this case, my moving actors game attribute goes to negative number while they are stopped.
  • monkeedmonkeed Member Posts: 22
    That did it, thank you,
Sign In or Register to comment.