playMaker

Author Topic: [SOLVED] Difference between two floats  (Read 3537 times)

charming_fox

  • Junior Playmaker
  • **
  • Posts: 62
[SOLVED] Difference between two floats
« on: May 11, 2014, 05:54:23 PM »
Hi!

Maths is not my strong point, I'm getting confused when trying to figure out the difference between two float variables... one is a horizontal, one is a vertical, I want one float to win out against the other based on it's position from zero... so a X70 would win against a Y60 but a X50 would lose against a Y-55... Im staring at float operator and coming up blank.... the result needs to work within the one FSM and will be used within an animation graph. Hope you guys can help.

Thanks
« Last Edit: May 12, 2014, 03:02:37 AM by charming_fox »

jess84

  • Hero Member
  • *****
  • Posts: 515
Re: Difference between two floats
« Reply #1 on: May 11, 2014, 07:19:04 PM »
Interesting question.

I doubt I have the maths skills to come up with the best answer, but you could...

use Float Sign Test to check for negative numbers, and if there's a match, then flip it to a positive number (* -1) - that way all of your numbers will be positive and you can compare them normally.

TrentSterling

  • Junior Playmaker
  • **
  • Posts: 89
  • Someday I'll make games!
    • My Blog
Re: Difference between two floats
« Reply #2 on: May 11, 2014, 08:47:07 PM »
I imagine using Float Abs (Absolute value) would be faster than manually changing its sign.


Without knowing what this is really for, I made a basic action group here:



I figure you don't want to lose the X and Y variables, so you copy them to temp vars for the Abs operation.

EDIT: In the screenshot, YBig is fired because even though its -100, it's still the 'bigger' value.

charming_fox

  • Junior Playmaker
  • **
  • Posts: 62
Re: Difference between two floats
« Reply #3 on: May 12, 2014, 02:14:04 AM »
Thanks guys I'll give these a go and post the results and hopefully it'll serve to help others one day.

charming_fox

  • Junior Playmaker
  • **
  • Posts: 62
Re: Difference between two floats
« Reply #4 on: May 12, 2014, 03:02:07 AM »
Going to take some faffing to get this to work (as always) but the float abs seems to be the key, thanks for you help both of you. For those, like me, who didn't know what a Float Abs was, here's a short video explaining it!