playMaker

Author Topic: [Solved] float compare problem  (Read 3120 times)

[?]Anykey

  • Playmaker Newbie
  • *
  • Posts: 6
[Solved] float compare problem
« on: November 29, 2012, 07:34:07 AM »
Hello everyone. I'm having a bit of trouble and I'm wondering if you could help me out.

Controller move and controller simple move (for me) does not work together with a get distance and float compare.
The float compare stops working and does not exit the state when the object is within correct distance to its target.

Using move towards would be ideal but I have to include gravity in speed to get it to be able to walk down hill and using a controller move/controller simple move in the same state with a move towards causes the move towards to stop working.
Sometimes it works once but then stops and it walks passed its target.

Any idea on how to fix or work around this?

edit: Forgot to mention I am running unity 3.5.6f4 and I'm using the latest playmaker version.
I am also using a modified controller move created by Jean Fabre
http://www.sendspace.com/file/w5wb3f

Thanks!
« Last Edit: December 01, 2012, 09:00:15 AM by [?]Anykey »

DARK_ETERNAL

  • Full Member
  • ***
  • Posts: 110
Re: float compare problem
« Reply #1 on: November 29, 2012, 10:44:17 AM »
In 1st place, why would you use a Controller (simple) move with Float Compare? What would you be "comparing"?

You can isolate the controller move in an FSM and store the position, perhaps a component, and in another FSM, retrieve that position or point to calculate the distance between your character and whatever you want to have noticed when your character is within correct distance.
Check out our new game: Nitro Chimp. Now live in App Store!

Trailer:
Download: https://itunes.apple.com/app/nitro-chimp/id557150450?l=en&mt=8

[?]Anykey

  • Playmaker Newbie
  • *
  • Posts: 6
Re: float compare problem
« Reply #2 on: November 30, 2012, 03:34:15 AM »
Thanks for you response. As I stated to move the object towards the target and compare the distance between them both while doing it using a get distance and float compare. Then when the object is within the correct distance exit the state (aka stop moving).

Yeah sure I can do that, I just didn't want to add any more to it unless it was really needed.
My ai setup already has a lot of stuff on it :)

Thanks

DARK_ETERNAL

  • Full Member
  • ***
  • Posts: 110
Re: float compare problem
« Reply #3 on: November 30, 2012, 10:16:47 AM »
Remember PlayMaker's motto: Use smaller intercommunicated FSMs instead of bigger and complex ones.
My words: Divide et vinces (divide and conquer).

Sometimes you will find useful, and very practical, to divide your FSM into smaller ones, so you can build even more complex systems relying in event sending. I don't know if you actually need this, but, if I was you, I'd do it that way, for simplicity, to get an loosely coupled AI and to gain some time.

Greetings.
Check out our new game: Nitro Chimp. Now live in App Store!

Trailer:
Download: https://itunes.apple.com/app/nitro-chimp/id557150450?l=en&mt=8

[?]Anykey

  • Playmaker Newbie
  • *
  • Posts: 6
Re: float compare problem
« Reply #4 on: December 01, 2012, 05:02:18 AM »
Thanks for the tip! I'll remember to do that for future things