Topic: Stance change triggered by life.

Can I trigger stance change by low life?

Share

Thumbs up Thumbs down

Re: Stance change triggered by life.

You can achieve this by using the OnLifePointsChange event, then accessing the stance change function like this:

using UnityEngine;
using UFE3D;

public class ChangeStance : MonoBehaviour
{
    private bool rageMode;

    private void Start()
    {
        UFE.OnLifePointsChange += this.OnLifePointsChange;
    }

    void OnLifePointsChange(float newLifePoints, ControlsScript player)
    {
        if (!rageMode && player.currentLifePoints <= 20)
        {
            rageMode = true;
            player.MoveSet.ChangeMoveStances(CombatStances.Stance2);
        }
    }
}

For more on coding events check out this page:
http://www.ufe3d.com/doku.php/code#global_events

Like UFE? Please rate and review us on the Asset Store!
Questions about the Forum? Check out our Karma FAQ.

Re: Stance change triggered by life.

Mistermind wrote:

You can achieve this by using the OnLifePointsChange event, then accessing the stance change function like this:

using UnityEngine;
using UFE3D;

public class ChangeStance : MonoBehaviour
{
    private bool rageMode;

    private void Start()
    {
        UFE.OnLifePointsChange += this.OnLifePointsChange;
    }

    void OnLifePointsChange(float newLifePoints, ControlsScript player)
    {
        if (!rageMode && player.currentLifePoints <= 20)
        {
            rageMode = true;
            player.MoveSet.ChangeMoveStances(CombatStances.Stance2);
        }
    }
}

For more on coding events check out this page:
http://www.ufe3d.com/doku.php/code#global_events

Interesting, this script should be added directly to the character?

Me encontraste en un negro camino como un peregrino sin rumbo ni fe, pero la luz de tus ojos divinos cambió mi suerte por dicha y placer.

Re: Stance change triggered by life.

I think you could add that directly to the scene.
It looks like that script might also effect both players.

Share

Thumbs up Thumbs down