YesNoOk
avatar

RootDist (Triggers) (Read 2870 times)

Started by Just No Point, October 22, 2015, 04:14:07 am
Share this topic:
RootDist (Triggers)
#1  October 22, 2015, 04:14:07 am
  • ******
    • www.justnopoint.com/
This trigger is only valid for helper-type characters. RootDist returns the distance from the helper to its root. The root is the main player character who owns the helper: for instance, if you select Kumquat to play with, and Kumquat spawns a helper named Kiwi, who in turn spawns a helper named Penguin, then Penguin's root is Kumquat, and Penguin is a descendant of Kumquat. RootDist works similarly to P2Dist.

Format:
RootDist [component]

Arguments:
[component]
X, Y

Return type:
float

Error conditions:
Returns bottom if the player has no root.

Details:
For comparing the Y-distance, RootDist gives the difference in the heights of the players' Y-axes. A negative value means that the root is above its descendant.

For comparing the X-distance, ParentDist gives the X-distance of the root's axis from the descendant's axis. A positive value indicates the root is in front of its descendant.

Example:

Code:
trigger1 = RootDist X != 0
  Triggers if the root is not at the exact same x-position as the
  helper character.
Re: RootDist (Triggers)
New #2  October 25, 2015, 02:29:19 am
  • *****
  • Shame on you!
    • USA
One major thing to point out. Comparing X distances can become super tricky when the root and the child go around Player 2.
I've made a little image to help sort this out.

The Rootdist X will be negative if it's between P1 and P2. If it goes onto the other side of P2 it will become positive.
I suspect that this is because of Facing. I havent tested with autoturn off.
vVv Wheat Stage Released vVv
Last Edit: October 27, 2015, 03:50:25 pm by Just No Point
Re: RootDist (Triggers)
#3  October 25, 2015, 03:05:47 am
  • ****
  • stillRetired.
  • Formerly Known As Genesis
    • USA
    • www.mediafire.com/folder/7j1slkpa7lm0w/Public_Works
I had no idea this trigger existed.

As unconventional as this is, you could in theory use this to have a helper destroy itself when it's a certain distance from the root, or maybe a little more conventionally, explode in that case, right?
Re: RootDist (Triggers)
#4  October 25, 2015, 03:37:26 am
  • *****
  • Shame on you!
    • USA
Yeah you could do that pretty easy. But if the helper and the player both move it may never happen. The helper has to be the set distance away and if P1 approaches him, that distance wont ever hit.
It could be used to affect the palette so it glows different colors. As it gets closer or further it could change colors.
vVv Wheat Stage Released vVv
Re: RootDist (Triggers)
#5  October 26, 2015, 01:34:49 am
  • ****
  • High AF
    • USA
    • Skype - DJHANNIBALROYCEUSA
    • sites.google.com/site/djhrmugen/
the more you know......


i love that palette idea. i may have to use that in the future.
WiiU Username: DJHANNIBALROYCE7
Re: RootDist (Triggers)
#6  October 26, 2015, 08:46:32 pm
  • ****
  • Robotics Engineer
    • USA
    • altoiddealer@gmail.com
One major thing to point out. Comparing X distances can become super tricky when the root and the child go around Player 2.

The Rootdist X will be negative if it's between P1 and P2. If it goes onto the other side of P2 it will become positive.
I suspect that this is because of Facing. I havent tested with autoturn off.

If only the absolute distance is necessary (example: you want a helper to destroy itself if it strays too far), then this issue could be alleviated with abs:
trigger1 = abs(RootDist X) > 100

But yeah as you suspect, RootDist, ParentDist, etc will all return either a positive or a negative number depending on the helper/parent facing