What's the best way to detect if Dva is in mech?

I tried to detect max health, but it doesn’t seem to work correctly.
Please help if you can, thank you.

Set Player Variable At Index(Event Player, H, 1, Add(Subtract(Y Component Of(Eye Position(Event Player)), Y Component Of(Position Of(Event Player))), 0.4));


rule("D.Va")
{
    event
    {
        Ongoing - Each Player;
        All;
        D.Va;
    }
    conditions
    {
        Is Button Held(Event Player, Ability 2) == True;
        Is Crouching(Event Player) == False;
    }
    actions
    {
        Start Holding Button(Event Player, Ability 2);

        Skip If(Compare(Value In Array(Player Variable(Event Player, H), 1), <, 2), 5);
            Set Status(Event Player, Event Player, Unkillable, 1);
            Kill(Event Player, Event Player);
            Damage(Event Player, Event Player, Max Health(Event Player));
            Wait(1, Ignore Condition);
            Skip(4);
                Set Ultimate Charge(Event Player, 100);
                Press Button(Event Player, Ultimate);
                Wait(0.5, Ignore Condition);
                Set Ultimate Charge(Event Player, 0);
        Set Player Variable At Index(Event Player, H, 1, Add(Subtract(Y Component Of(Eye Position(Event Player)), Y Component Of(Position Of(Event Player))), 0.4));
        Stop Holding Button(Event Player, Ability 2);
    }
}

Thank you, I’ll try that.

Check the eye height of the player. It’s different when she’s in and out of mech.

Edit:
You’ll have to check if it’s within a range, as crouching will affect this value

Edit 2:
The function you’re looking for is actually something like “Eye Position” and it’s relative to the world. In order to get the “Eye Height” that’s relative to the player, you’ll have to do:
Y Component Of( EyePosition(Event Player) - PositionOf(Event Player) )

Ah, ok, that’d be simpler, thank you.

Oh I didn’t actually see you put that at the top lol. One question though: why do you add 0.4?

It works! Huzzah! Many thanks!

1 Like

I think that the position of the eye Y minus the position of the character Y is not equal to the true height of the character. The position of the camera is usually located in the body part rather than the eye position in the usual sense.

The “eye position” of the Dva mech is quite far below the height of it, as Dva is sitting inside of it. The others I believe are just slightly below the top of their skull?

Although there are some obvious perspective differences between 1st/3rd person, that, 0.4 seems like quite a big number tbh. :o

Unless 0.4 is a value specific to D.va?

All heroes are different, but I think 0.4 is an approximate average

One thing I’ll point out for anyone using the Max Health method: watch out for Lúcio’s ultimate.