playMaker

Author Topic: Check for Motion/Movement  (Read 2472 times)

flo123

  • Playmaker Newbie
  • *
  • Posts: 3
Check for Motion/Movement
« on: April 04, 2014, 07:18:51 AM »
Hey guys!
Has anyone of you had a situation, where you wanted Playmaker to check if there is a movement on an object (not player) going on, and if so, do XY (play animation/sound)?

I tried to come up with something that stores the position each frame and compares it with the one from last frame, but I could not get it to work.

Any suggestions on this?
Thanks!
Flo!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Check for Motion/Movement
« Reply #1 on: April 04, 2014, 07:28:48 AM »
Hi,

 yes, you are going in the right direction. You need two vector 3 variable, the current position and the last position you detected movement.

1: get the current position
2: compare with the last position, if different, fire an event AND set last position to current position.


 Bye,

 Jean

flo123

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Check for Motion/Movement
« Reply #2 on: April 04, 2014, 07:43:37 AM »
Thank you very much for the instant response!
That is exactly what I had in mind (more or less hehe) - now, as a newbie, I just struggle with how to compare the vector3 variables with each other.

I thought about converting the variables to strings or something, to be able to compare those, but I can't find any apropriate Action for that.

Feel ashamed for asking again...
Sorry and thanks!
Flo

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Check for Motion/Movement
« Reply #3 on: April 04, 2014, 08:06:06 AM »
Hi,

 to do that, you would use "vector3 operator", get the distance as a float, if that float is greater then say 0.1 ( give it a bit of marging, it's more predictable), using "float compare" action, then you know if the object moved.

 Now, IF your object is a rigidBody, simply get the velocity and simply use "get speed" action and compare the speed against 0.1 as well.

 Bye,

 Jean