Playmaker Forum
PlayMaker Updates & Downloads => Share New Actions => Topic started by: jeanfabre on February 21, 2012, 07:20:11 AM
-
Hi,
Sometimes it becomes necessary to lerp vector position against deltatime. This version of Vector3Lerp implements a flag to just do that.
// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved.
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Vector3)]
[Tooltip("Linearly interpolates between 2 vectors. it also lets you lerp against deltatime")]
public class Vector3Lerp2 : FsmStateAction
{
[RequiredField]
[Tooltip("First Vector.")]
public FsmVector3 fromVector;
[RequiredField]
[Tooltip("Second Vector.")]
public FsmVector3 toVector;
[RequiredField]
[Tooltip("Interpolate between From Vector and ToVector by this amount. Value is clamped to 0-1 range. 0 = From Vector; 1 = To Vector; 0.5 = half way between.")]
public FsmFloat amount;
[Tooltip("amount is multiplied by the deltatime")]
public bool lerpAgainstDeltaTime;
[RequiredField]
[UIHint(UIHint.Variable)]
[Tooltip("Store the result in this vector variable.")]
public FsmVector3 storeResult;
[Tooltip("Repeat every frame. Useful if any of the values are changing.")]
public bool everyFrame;
public override void Reset()
{
fromVector = new FsmVector3 { UseVariable = true };
toVector = new FsmVector3 { UseVariable = true };
storeResult = null;
lerpAgainstDeltaTime = false;
everyFrame = true;
}
public override void OnEnter()
{
DoVector3Lerp();
if (!everyFrame)
{
Finish();
}
}
public override void OnUpdate()
{
DoVector3Lerp();
}
void DoVector3Lerp()
{
if (lerpAgainstDeltaTime)
{
storeResult.Value = Vector3.Lerp(fromVector.Value, toVector.Value, Time.deltaTime*amount.Value);
}else{
storeResult.Value = Vector3.Lerp(fromVector.Value, toVector.Value, amount.Value);
}
}
}
}
Bye,
Jean
-
Great flag, thanks Jean!! This is really useful if you want to have smooth movement, damping etc.
Please add this to the standard vector3/vector2/float lerp action
-
Hi,
ok, I have updated all the ecosystem actions I think could get this nice additions, let me know if you see others.
Bye,
Jean
-
Great! Thanks Jean!
I saw these actions without flag deltatime:
- float lerp
- float lerp advanced
- quaternation slerp
I think this feature is useful for many actions! This is the only way to make sure behavior is the same while running on different framerates (like per second feature). Actions depending on time could benefit of deltatime, like "move towards" or "rotate towards".
btw, I really enjoy using the ecobrowser!
-
Hi,
ok, FloatLerp is done
Float Lerp advanced has this option it's in the type of interpolation, choose "deltaTime".
and Quaternion Slerp was already with this addition, maybe I did it and forgot to post here right after .
Bye,
Jean
-
...and Quaternion Slerp was already with this addition, maybe I did it and forgot to post here right after .
(http://oi62.tinypic.com/ftpybk.jpg)
https://github.com/jeanfabre/PlayMakerCustomActions_U3/blob/master/Assets/PlayMaker%20Custom%20Actions/Quaternion/QuaternionLerp.cs
https://github.com/jeanfabre/PlayMakerCustomActions_U3/blob/master/Assets/PlayMaker%20Custom%20Actions/Quaternion/QuaternionSlerp.cs
QuaternionSlerp is without "DeltaTime" checkbox ?
-
Hi,
You need to delete the action and download it again. The next version of the ecosystem will allow you to delete from the browser itself, so it will be easier to do these updates. And I am working actively on a versioning systems so that I can even detect and prompt you for updates automatically.
Bye,
Jean
-
Hi,
I delete QuaternionSlerp action and download it again... but there are is
no checkbox for "Lerp Against Delta Time". Maybe this checkbox is only for
Lerp and Slerp use DeltaTime by default, without checkbox?
-
d'oh :)
I forgot to update the Custom Editor. re download please :)
Delete manually the script "QuaternionLerpCustomEditor" if necessary.
That's a good case for me to take in consideration for more intuitive updates from the the Ecosystem.
Bye,
Jean
-
Finally "DeltaTime" Lerp/Slerp/Vector3/Quaternion... :)
That was very important for multiplayer games.
You can move this Trello Card to "DONE"
https://trello.com/c/Sd1J0JQV/23-quaternion-package-update
Thank you so much!
-
Hi,
Thanks for reminding me about the trello task :)
Bye,
Jean