maint: various clean up, movement tweaks, and smoothing fixes
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using Unity.Mathematics.Geometry;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Reset.Units {
|
||||
@@ -13,6 +14,13 @@ namespace Reset.Units {
|
||||
[SliderField(0, 1)]
|
||||
public BBParameter<float> relativity;
|
||||
|
||||
[Tooltip("If using during execute, multiply by delta time")]
|
||||
[Space(5)] public BBParameter<bool> deltaTime;
|
||||
|
||||
[Tooltip("This is only used if the value is set in an Update loop. Set to 0 to remove decay")]
|
||||
public BBParameter<float> decayRate;
|
||||
|
||||
|
||||
//Use for initialization. This is called only once in the lifetime of the task.
|
||||
//Return null if init was successfull. Return an error string otherwise
|
||||
protected override string OnInit() {
|
||||
@@ -23,13 +31,23 @@ namespace Reset.Units {
|
||||
//Call EndAction() to mark the action as finished, either in success or failure.
|
||||
//EndAction can be called from anywhere.
|
||||
protected override void OnExecute() {
|
||||
agent.SetNewGravity(newGravity.value, relativity.value, absolute.value);
|
||||
EndAction(true);
|
||||
|
||||
}
|
||||
|
||||
//Called once per frame while the action is active.
|
||||
protected override void OnUpdate() {
|
||||
protected override void OnUpdate(){
|
||||
float finalValue = newGravity.value ;
|
||||
|
||||
if (decayRate.value != 0) {
|
||||
finalValue -= decayRate.value * elapsedTime;
|
||||
}
|
||||
|
||||
if (deltaTime.value) {
|
||||
finalValue *= Time.deltaTime;
|
||||
}
|
||||
|
||||
agent.SetNewGravity(finalValue, relativity.value, absolute.value);
|
||||
EndAction(true);
|
||||
}
|
||||
|
||||
//Called when the task is disabled.
|
||||
|
||||
Reference in New Issue
Block a user