34 lines
1.1 KiB
C#
34 lines
1.1 KiB
C#
using UnityEngine;
|
|
|
|
namespace Invector.vCharacterController.AI.FSMBehaviour
|
|
{
|
|
public class vGetPlayerDistance : vStateAction
|
|
{
|
|
public override string categoryName
|
|
{
|
|
get { return "Custom Example/"; }
|
|
}
|
|
|
|
public override string defaultName
|
|
{
|
|
get { return "Get Player Distance"; }
|
|
}
|
|
|
|
public AnimationCurve postionOffset = AnimationCurve.Linear(-20f, -20f, 20f, 20f);
|
|
public string parameterName = "";
|
|
|
|
public override void DoAction(vIFSMBehaviourController fsmBehaviour, vFSMComponentExecutionType executionType = vFSMComponentExecutionType.OnStateUpdate)
|
|
{
|
|
if (!fsmBehaviour.aiController.currentTarget.transform) return;
|
|
var targetPosition = fsmBehaviour.aiController.currentTarget.transform;
|
|
|
|
float floatValue = fsmBehaviour.transform.InverseTransformPoint(targetPosition.position).z;
|
|
|
|
if (!string.IsNullOrEmpty(parameterName))
|
|
{
|
|
fsmBehaviour.aiController.animator.SetFloat(parameterName, postionOffset.Evaluate(floatValue));
|
|
}
|
|
}
|
|
}
|
|
}
|