changed: changing some air movement values can now be smoothed (including values that are used to smoothing out inputs)
This commit is contained in:
@@ -147,7 +147,7 @@ namespace NodeCanvas.Tasks.Actions {
|
||||
public void UpdateFloatValue(FloatValueGroup valueGroup, ref CameraSettingSingleValue<float> targetProperty){
|
||||
switch (valueGroup.changeValue) {
|
||||
case ValueChangeAction.NewValue:
|
||||
targetProperty.targetValue = valueGroup.value;
|
||||
targetProperty.targetValue = valueGroup.value.value;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
targetProperty.targetValue = targetProperty.originalValue;
|
||||
|
||||
@@ -40,6 +40,7 @@ namespace Reset.Core {
|
||||
public FloatValueGroup gravityMax = new (newLabel: "Gravity Max");
|
||||
public FloatValueGroup gravityAcceleration = new (newLabel: "Gravity Acceleration Speed");
|
||||
public FloatValueGroup gravityScale = new (newLabel: "Gravity Scale");
|
||||
public FloatValueGroup settingsChangeSmoothing = new(newLabel: "Settings Change Smoothing");
|
||||
|
||||
// Rotation
|
||||
[ParadoxNotion.Design.Header("Rotation")]
|
||||
@@ -97,6 +98,7 @@ namespace Reset.Core {
|
||||
UpdateFloatValue(gravityMax, ref agent.data.gravityMax, ref agent.defaultData.gravityMax);
|
||||
UpdateFloatValue(gravityAcceleration, ref agent.data.gravityAcceleration, ref agent.defaultData.gravityAcceleration);
|
||||
UpdateFloatValue(gravityScale, ref agent.data.gravityScale, ref agent.defaultData.gravityScale);
|
||||
UpdateFloatValue(settingsChangeSmoothing, ref agent.data.settingsChangeSmoothing, ref agent.data.settingsChangeSmoothing);
|
||||
|
||||
// Rotation
|
||||
UpdateEnumValue(rotateFacing, ref agent.data.rotateFacing, ref agent.defaultData.rotateFacing);
|
||||
@@ -222,7 +224,7 @@ namespace Reset.Core {
|
||||
public void UpdateFloatValue(FloatValueGroup valueGroup, ref float targetProperty, ref float defaultProperty){
|
||||
switch (valueGroup.changeValue) {
|
||||
case ValueChangeAction.NewValue:
|
||||
targetProperty = valueGroup.value;
|
||||
targetProperty = valueGroup.value.value;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
targetProperty = defaultProperty;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using NodeCanvas.Editor;
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
@@ -97,13 +99,14 @@ namespace Reset.Core{
|
||||
|
||||
public struct FloatValueGroup{
|
||||
public string label;
|
||||
public float value;
|
||||
// public float value;
|
||||
public BBParameter<float> value;
|
||||
|
||||
public ValueChangeAction changeValue;
|
||||
|
||||
public FloatValueGroup(string newLabel){
|
||||
label = newLabel;
|
||||
value = 0f;
|
||||
value = new BBParameter<float>().value = 0f;
|
||||
changeValue = ValueChangeAction.NoChange;
|
||||
}
|
||||
}
|
||||
@@ -123,7 +126,7 @@ namespace Reset.Core{
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public class BoolValueGroupDrawer : ObjectDrawer<BoolValueGroup> {
|
||||
public override BoolValueGroup OnGUI(GUIContent content, BoolValueGroup _instance){
|
||||
public override BoolValueGroup OnGUI(GUIContent _content, BoolValueGroup _instance){
|
||||
// Remove label for floats
|
||||
EditorGUIUtility.labelWidth = 50;
|
||||
|
||||
@@ -274,9 +277,11 @@ namespace Reset.Core{
|
||||
// Create the x settings enum
|
||||
_instance.changeValue = (ValueChangeAction)EditorGUILayout.EnumPopup("", instance.changeValue);
|
||||
|
||||
|
||||
// Create the value/disabled information field
|
||||
if (_instance.changeValue == ValueChangeAction.NewValue){
|
||||
_instance.value = EditorGUILayout.FloatField(_instance.value, floatOptions);
|
||||
// _instance.value = EditorGUILayout.FloatField(_instance.value, floatOptions);
|
||||
BBParameterEditor.ParameterField("", _instance.value);
|
||||
} else {
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
EditorGUILayout.TextField(_instance.changeValue == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions);
|
||||
|
||||
@@ -44,6 +44,7 @@ namespace Reset.Units{
|
||||
public float gravityMax = 8f;
|
||||
public float gravityAcceleration = 1f;
|
||||
public float gravityScale = 1f;
|
||||
public float settingsChangeSmoothing = 6f;
|
||||
|
||||
// Rotation
|
||||
[ShowInInspector, SerializeReference]
|
||||
@@ -72,6 +73,12 @@ namespace Reset.Units{
|
||||
[ShowInInspector, ReadOnly] private Quaternion specifiedRotation;
|
||||
[ShowInInspector, ReadOnly] private float outputRotationSpeed;
|
||||
|
||||
// Used by graph to gradually shift into new values rather than dump them. Even if they're smoothed values they need to be eased into
|
||||
[ShowInInspector, ReadOnly] private float outputJumpDecay;
|
||||
[ShowInInspector, ReadOnly] private float outputGravityAccel;
|
||||
[ShowInInspector, ReadOnly] private float outputGravityScale;
|
||||
[ShowInInspector, ReadOnly] private float settingsChangeRotationSpeed;
|
||||
|
||||
private float directionChangeDot;
|
||||
private bool moveCallDisabledNextFrame;
|
||||
|
||||
@@ -204,7 +211,7 @@ namespace Reset.Units{
|
||||
// Update the gravity, called every frame
|
||||
private void UpdateCurrentGravity(){
|
||||
// Accelerate gravity
|
||||
// data.gravityPower += data.gravityAcceleration * Time.deltaTime;
|
||||
data.gravityPower += outputGravityAccel * Time.deltaTime;
|
||||
data.gravityPower = Mathf.Clamp(data.gravityPower, Mathf.NegativeInfinity, data.gravityMax);
|
||||
|
||||
// Apply a constant gravity if the player is grounded
|
||||
@@ -263,7 +270,7 @@ namespace Reset.Units{
|
||||
}
|
||||
|
||||
// Calculate rotation speed, as in how fast the fella rotates. This value has it's own smoothing to allow for gradual increasing/decreasing of the speed till it reaches the target
|
||||
outputRotationSpeed = Mathf.Lerp(outputRotationSpeed, data.rotationSpeed, data.rotationSmoothing * Time.deltaTime);
|
||||
outputRotationSpeed = Mathf.Lerp(outputRotationSpeed, data.rotationSpeed, settingsChangeRotationSpeed * Time.deltaTime);
|
||||
|
||||
// Set final rotation
|
||||
transform.rotation = Quaternion.Slerp(transform.rotation, outputRotation, outputRotationSpeed * Time.deltaTime).Flatten(0, null, 0);
|
||||
@@ -298,7 +305,7 @@ namespace Reset.Units{
|
||||
|
||||
// Add their related speeds
|
||||
moveXZDir *= speed * Time.deltaTime;
|
||||
moveYDir *= gravityScale * Time.deltaTime;
|
||||
moveYDir *= outputGravityScale * Time.deltaTime;
|
||||
addDir *= additionalSpeed * Time.deltaTime;
|
||||
|
||||
// Construct the direction and move
|
||||
@@ -314,6 +321,14 @@ namespace Reset.Units{
|
||||
void LateUpdate(){
|
||||
UpdateGravityLate();
|
||||
DecayAdditionalDirection();
|
||||
SmoothingSettingsChanges();
|
||||
}
|
||||
|
||||
private void SmoothingSettingsChanges(){
|
||||
outputJumpDecay = Mathf.Lerp(outputJumpDecay, data.jumpPowerDecay, data.settingsChangeSmoothing * Time.deltaTime);
|
||||
outputGravityAccel = Mathf.Lerp(outputGravityAccel, data.gravityAcceleration, data.settingsChangeSmoothing * Time.deltaTime);
|
||||
outputGravityScale = Mathf.Lerp(outputGravityScale, data.gravityScale, data.settingsChangeSmoothing * Time.deltaTime);
|
||||
settingsChangeRotationSpeed = Mathf.Lerp(settingsChangeRotationSpeed, data.rotationSpeed, data.settingsChangeSmoothing * Time.deltaTime);
|
||||
}
|
||||
|
||||
void DecayAdditionalDirection(){
|
||||
@@ -343,7 +358,7 @@ namespace Reset.Units{
|
||||
|
||||
private void UpdateGravityLate(){
|
||||
// Decay jump power
|
||||
data.jumpPower -= data.jumpPowerDecay * Time.deltaTime;
|
||||
data.jumpPower -= outputJumpDecay * Time.deltaTime;
|
||||
data.jumpPower = Mathf.Max(0f, data.jumpPower);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user