playMaker

Author Topic: Get Velocity or Speed without physics?  (Read 3742 times)

kavery

  • Full Member
  • ***
  • Posts: 149
Get Velocity or Speed without physics?
« on: January 27, 2017, 10:45:52 AM »
I'm using a 'move towards' action on a walking enemy and would like to know when this enemy is stuck behind a collider. The problem is the walk animation continues because the 'move towards' target is on the other side of the collider and never finishes. The collider pushes back momentum, negating the enemy walk speed.

In most cases the enemy walks around the collider, meets the target and idles but not always. I can't simply detect a collider and trigger an idle, because often times you walk along side other enemies and I don't want them stopping every time they get close.

I'm thinking the best work around is to determine speed during the move towards action. I could do a compare and exit state when it's 0. I tried 'get velocity' with no luck. I have a rigid body attached. Using gravity is the only way I can get any variable beyond 0.

I could get the distance to target, but then how do I reference lapsed time? Maybe I need to make a separate FSM (trying to avoid that) that receives the distance variable. Then between two states I can subtract distance and determine time past. But I'd prefer to have the compare happen inside the same state as the 'move towards'.

 

600

  • Beta Group
  • Hero Member
  • *
  • Posts: 715
    • Flashing Lights
Re: Get Velocity or Speed without physics?
« Reply #1 on: January 27, 2017, 11:09:20 AM »
There is an action on Ecosystem: Game Object Speed
Great for case where you don't move with physics.

kavery

  • Full Member
  • ***
  • Posts: 149
Re: Get Velocity or Speed without physics?
« Reply #2 on: January 27, 2017, 11:20:09 AM »
Oh wow, never saw that one after all the searches. Can't wait to try this. Thank you.

kavery

  • Full Member
  • ***
  • Posts: 149
Re: Get Velocity or Speed without physics?
« Reply #3 on: January 27, 2017, 11:44:04 PM »
When I use GameObjectSpeed I get feedback, but when the GO stops moving the number stays where it was and doesn't go to zero? In this case usually around 2.0.

600

  • Beta Group
  • Hero Member
  • *
  • Posts: 715
    • Flashing Lights
Re: Get Velocity or Speed without physics?
« Reply #4 on: January 28, 2017, 04:07:33 AM »
That is odd, is it set every frame and is the state with that action active when the object stops?

kavery

  • Full Member
  • ***
  • Posts: 149
Re: Get Velocity or Speed without physics?
« Reply #5 on: January 30, 2017, 08:50:48 AM »
The action is automatically every frame. You raise a good point about being in the state.. I think you may be right. I need to look closer at that.