Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: charming_fox on May 11, 2014, 05:54:23 PM

Title: [SOLVED] Difference between two floats
Post by: charming_fox 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
Title: Re: Difference between two floats
Post by: jess84 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.
Title: Re: Difference between two floats
Post by: TrentSterling 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:

(http://i.imgur.com/ERVjC2V.jpg)

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.
Title: Re: Difference between two floats
Post by: charming_fox 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.
Title: Re: Difference between two floats
Post by: charming_fox 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!