playMaker

Author Topic: How to check: "player is moving"?  (Read 4622 times)

dougbello

  • Playmaker Newbie
  • *
  • Posts: 32
How to check: "player is moving"?
« on: July 26, 2015, 12:39:50 AM »
Hello,

I want to make an action to kill my "set velocity" when my player hits an obstacle... I've tried with triggers, raycast etc. but nothing works because when the player jumps and collide it gets deep inside the objects, due to limitations on unity engine vs performance....

So I'm thinking a good way to controll it would be to make an action that compares if (while I press the button for velocity) it compares if the player moved from last frame. If the player is in the same position, it means it's stuck...

I've tried with get velocity and get speed, but to my surprise both commands give me more than 0 when i'm pressing the set velocity command, even when the player is absolutely not moving. My velocity is set to 5.7, and when the character is stuck the get velocity gives me 5.3 and it was supose to give me 0 right?

Any ideas on how to compare the position from last frame to the current frame? And they have to work inside the same "node" on my fsm... witch is the same node i'm setting the velocity.

Thanks.
Doug

« Last Edit: July 27, 2015, 01:32:05 PM by dougbello »

DarkSoul

  • Playmaker Newbie
  • *
  • Posts: 37
Re: How to know if player is moving?
« Reply #1 on: July 26, 2015, 12:17:00 PM »
Hello ,

Using get position and assign it to a float variable, you can test float changed action.

I hope this helps.

dougbello

  • Playmaker Newbie
  • *
  • Posts: 32
Re: How to know if player is moving?
« Reply #2 on: July 26, 2015, 12:44:49 PM »
Hey DarkSoul thanks for helping again.

I tried that, but the "float changed" is too sensible for my needs. When I use it, even if i'm moving it gives false positives and stops the player sometimes, I think it has a very small frame rate compare, and sometimes it doesnt give enough time for the float to update correctly.

I need something a bit more flexible, to check if its moved since last 2 frames or so. It has to be flexible because its an action to be executed in an extreme case, just when i'm pressing the foward button and the player is not moving for some time, then it means its stuck.

Thanks.
Doug.

dougbello

  • Playmaker Newbie
  • *
  • Posts: 32
Re: How to know if player is moving?
« Reply #3 on: July 27, 2015, 10:38:17 AM »
Really, there is no way of checking if my player is moving in the x while pressing a key with playmaker?


terri

  • Sr. Member
  • ****
  • Posts: 389
    • terrivellmann.tumblr.com
Re: How to know if player is moving?
« Reply #4 on: July 27, 2015, 11:20:26 AM »
I've had to do something similar, I think I had a state that once a second compared the current position to last second's position, and if it they were closer togetger than X it would send a specific event.

dougbello

  • Playmaker Newbie
  • *
  • Posts: 32
Re: How to check: "player is moving"?
« Reply #5 on: July 27, 2015, 05:00:04 PM »
Hey terri, thank you...

I did that here, it works, i send a bool that checks for current vs 0.1 sec past position and it did the job, but everytime i release the touch to stop moving, it keeps running for some time and stops running buggy, really buggy. I would be awesome to have something like, get speed and get velocity working properly.

My game is almost ready for release, but this bug is really slowing me down here.