Hi,
Here is a quaternion lerp. Network being now accessible, these kind of function becomes necessary when synching players movement.
// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved.
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Transform)]
[Tooltip("Interpolates between from and to by t and normalizes the result afterwards.")]
public class QuaternionLerp : FsmStateAction
{
[RequiredField]
[Tooltip("From Quaternion.")]
public FsmQuaternion fromQuaternion;
[RequiredField]
[Tooltip("To Quaternion.")]
public FsmQuaternion toQuaternion;
[RequiredField]
[Tooltip("Interpolate between fromQuaternion and toQuaternion by this amount. Value is clamped to 0-1 range. 0 = fromQuaternion; 1 = toQuaternion; 0.5 = half way between.")]
public FsmFloat amount;
[RequiredField]
[UIHint(UIHint.Variable)]
[Tooltip("Store the result in this quaternion variable.")]
public FsmQuaternion storeResult;
[Tooltip("Repeat every frame. Useful if any of the values are changing.")]
public bool everyFrame;
public override void Reset()
{
fromQuaternion = new FsmQuaternion { UseVariable = true };
toQuaternion = new FsmQuaternion { UseVariable = true };
storeResult = null;
everyFrame = true;
}
public override void OnEnter()
{
DoQuatLerp();
if (!everyFrame)
{
Finish();
}
}
public override void OnUpdate()
{
DoQuatLerp();
}
void DoQuatLerp()
{
storeResult.Value = Quaternion.Lerp(fromQuaternion.Value, toQuaternion.Value, amount.Value);
}
}
}
Bye,
jean