change: more alterations to the new movement and settingvalue system
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -225,9 +225,9 @@ MonoBehaviour:
|
|||||||
currentSmoothing: 0
|
currentSmoothing: 0
|
||||||
currentValue: 0
|
currentValue: 0
|
||||||
refVel: 0
|
refVel: 0
|
||||||
deaccerlation:
|
deacceleration:
|
||||||
value: 6
|
value: 1
|
||||||
smoothing: 1
|
smoothing: 7.46
|
||||||
easing: 2
|
easing: 2
|
||||||
currentSmoothing: 0
|
currentSmoothing: 0
|
||||||
currentValue: 0
|
currentValue: 0
|
||||||
@@ -239,6 +239,13 @@ MonoBehaviour:
|
|||||||
currentSmoothing: 0
|
currentSmoothing: 0
|
||||||
currentValue: 0
|
currentValue: 0
|
||||||
refVel: 0
|
refVel: 0
|
||||||
|
softening:
|
||||||
|
value: 5
|
||||||
|
smoothing: 1
|
||||||
|
easing: 2
|
||||||
|
currentSmoothing: 0
|
||||||
|
currentValue: 0
|
||||||
|
refVel: 0
|
||||||
moveSpeed:
|
moveSpeed:
|
||||||
value: 10
|
value: 10
|
||||||
smoothing: 10
|
smoothing: 10
|
||||||
@@ -319,7 +326,7 @@ MonoBehaviour:
|
|||||||
currentSmoothing: 0
|
currentSmoothing: 0
|
||||||
currentValue: 0
|
currentValue: 0
|
||||||
refVel: 0
|
refVel: 0
|
||||||
deaccerlation:
|
deacceleration:
|
||||||
value: 0
|
value: 0
|
||||||
smoothing: 1
|
smoothing: 1
|
||||||
easing: 2
|
easing: 2
|
||||||
@@ -333,6 +340,13 @@ MonoBehaviour:
|
|||||||
currentSmoothing: 0
|
currentSmoothing: 0
|
||||||
currentValue: 0
|
currentValue: 0
|
||||||
refVel: 0
|
refVel: 0
|
||||||
|
softening:
|
||||||
|
value: 0
|
||||||
|
smoothing: 10
|
||||||
|
easing: 2
|
||||||
|
currentSmoothing: 0
|
||||||
|
currentValue: 0
|
||||||
|
refVel: 0
|
||||||
moveSpeed:
|
moveSpeed:
|
||||||
value: 0
|
value: 0
|
||||||
smoothing: 10
|
smoothing: 10
|
||||||
@@ -413,7 +427,7 @@ MonoBehaviour:
|
|||||||
currentSmoothing: 0
|
currentSmoothing: 0
|
||||||
currentValue: 0
|
currentValue: 0
|
||||||
refVel: 0
|
refVel: 0
|
||||||
deaccerlation:
|
deacceleration:
|
||||||
value: 0
|
value: 0
|
||||||
smoothing: 1
|
smoothing: 1
|
||||||
easing: 2
|
easing: 2
|
||||||
@@ -427,6 +441,13 @@ MonoBehaviour:
|
|||||||
currentSmoothing: 0
|
currentSmoothing: 0
|
||||||
currentValue: 0
|
currentValue: 0
|
||||||
refVel: 0
|
refVel: 0
|
||||||
|
softening:
|
||||||
|
value: 0
|
||||||
|
smoothing: 10
|
||||||
|
easing: 2
|
||||||
|
currentSmoothing: 0
|
||||||
|
currentValue: 0
|
||||||
|
refVel: 0
|
||||||
moveSpeed:
|
moveSpeed:
|
||||||
value: 0
|
value: 0
|
||||||
smoothing: 10
|
smoothing: 10
|
||||||
@@ -507,7 +528,7 @@ MonoBehaviour:
|
|||||||
currentSmoothing: 0
|
currentSmoothing: 0
|
||||||
currentValue: 0
|
currentValue: 0
|
||||||
refVel: 0
|
refVel: 0
|
||||||
deaccerlation:
|
deacceleration:
|
||||||
value: 0
|
value: 0
|
||||||
smoothing: 1
|
smoothing: 1
|
||||||
easing: 2
|
easing: 2
|
||||||
@@ -521,6 +542,13 @@ MonoBehaviour:
|
|||||||
currentSmoothing: 0
|
currentSmoothing: 0
|
||||||
currentValue: 0
|
currentValue: 0
|
||||||
refVel: 0
|
refVel: 0
|
||||||
|
softening:
|
||||||
|
value: 0
|
||||||
|
smoothing: 10
|
||||||
|
easing: 2
|
||||||
|
currentSmoothing: 0
|
||||||
|
currentValue: 0
|
||||||
|
refVel: 0
|
||||||
moveSpeed:
|
moveSpeed:
|
||||||
value: 0
|
value: 0
|
||||||
smoothing: 10
|
smoothing: 10
|
||||||
@@ -601,7 +629,7 @@ MonoBehaviour:
|
|||||||
currentSmoothing: 0
|
currentSmoothing: 0
|
||||||
currentValue: 0
|
currentValue: 0
|
||||||
refVel: 0
|
refVel: 0
|
||||||
deaccerlation:
|
deacceleration:
|
||||||
value: 0
|
value: 0
|
||||||
smoothing: 1
|
smoothing: 1
|
||||||
easing: 2
|
easing: 2
|
||||||
@@ -615,6 +643,13 @@ MonoBehaviour:
|
|||||||
currentSmoothing: 0
|
currentSmoothing: 0
|
||||||
currentValue: 0
|
currentValue: 0
|
||||||
refVel: 0
|
refVel: 0
|
||||||
|
softening:
|
||||||
|
value: 0
|
||||||
|
smoothing: 10
|
||||||
|
easing: 2
|
||||||
|
currentSmoothing: 0
|
||||||
|
currentValue: 0
|
||||||
|
refVel: 0
|
||||||
moveSpeed:
|
moveSpeed:
|
||||||
value: 0
|
value: 0
|
||||||
smoothing: 10
|
smoothing: 10
|
||||||
@@ -695,7 +730,7 @@ MonoBehaviour:
|
|||||||
currentSmoothing: 0
|
currentSmoothing: 0
|
||||||
currentValue: 0
|
currentValue: 0
|
||||||
refVel: 0
|
refVel: 0
|
||||||
deaccerlation:
|
deacceleration:
|
||||||
value: 0
|
value: 0
|
||||||
smoothing: 1
|
smoothing: 1
|
||||||
easing: 2
|
easing: 2
|
||||||
@@ -709,6 +744,13 @@ MonoBehaviour:
|
|||||||
currentSmoothing: 0
|
currentSmoothing: 0
|
||||||
currentValue: 0
|
currentValue: 0
|
||||||
refVel: 0
|
refVel: 0
|
||||||
|
softening:
|
||||||
|
value: 0
|
||||||
|
smoothing: 10
|
||||||
|
easing: 2
|
||||||
|
currentSmoothing: 0
|
||||||
|
currentValue: 0
|
||||||
|
refVel: 0
|
||||||
moveSpeed:
|
moveSpeed:
|
||||||
value: 0
|
value: 0
|
||||||
smoothing: 10
|
smoothing: 10
|
||||||
|
|||||||
@@ -42,23 +42,23 @@ namespace NodeCanvas.Tasks.Actions {
|
|||||||
//Call EndAction() to mark the action as finished, either in success or failure.
|
//Call EndAction() to mark the action as finished, either in success or failure.
|
||||||
//EndAction can be called from anywhere.
|
//EndAction can be called from anywhere.
|
||||||
protected override void OnExecute(){
|
protected override void OnExecute(){
|
||||||
OrbitalFollowValueGroup.UpdateValue(orbitFollowTop, ref CameraSettingsProcessor.data.orbitFollowTopHeight.value, ref CameraSettingsProcessor.original.orbitFollowTopRadius.value);
|
OrbitalFollowValueGroup.UpdateValue(orbitFollowTop, ref CameraSettingsProcessor.data.orbitFollowTopHeight.targetValue, ref CameraSettingsProcessor.original.orbitFollowTopRadius.targetValue);
|
||||||
OrbitalFollowValueGroup.UpdateValue(orbitFollowCenter, ref CameraSettingsProcessor.data.orbitFollowCenterHeight.value, ref CameraSettingsProcessor.original.orbitFollowCenterRadius.value);
|
OrbitalFollowValueGroup.UpdateValue(orbitFollowCenter, ref CameraSettingsProcessor.data.orbitFollowCenterHeight.targetValue, ref CameraSettingsProcessor.original.orbitFollowCenterRadius.targetValue);
|
||||||
OrbitalFollowValueGroup.UpdateValue(orbitFollowBottom, ref CameraSettingsProcessor.data.orbitFollowBottomHeight.value, ref CameraSettingsProcessor.original.orbitFollowBottomRadius.value);
|
OrbitalFollowValueGroup.UpdateValue(orbitFollowBottom, ref CameraSettingsProcessor.data.orbitFollowBottomHeight.targetValue, ref CameraSettingsProcessor.original.orbitFollowBottomRadius.targetValue);
|
||||||
|
|
||||||
Vector3ValueGroup.UpdateValue(cameraOffset, ref CameraSettingsProcessor.data.cameraOffsetOffset.value, ref CameraSettingsProcessor.original.cameraOffsetOffset.value);
|
Vector3ValueGroup.UpdateValue(cameraOffset, ref CameraSettingsProcessor.data.cameraOffsetOffset.targetValue, ref CameraSettingsProcessor.original.cameraOffsetOffset.targetValue);
|
||||||
|
|
||||||
Vector3ValueGroup.UpdateValue(orbitPositionDamping, ref CameraSettingsProcessor.data.orbitPositionDamping.value, ref CameraSettingsProcessor.original.cameraOffsetOffset.value);
|
Vector3ValueGroup.UpdateValue(orbitPositionDamping, ref CameraSettingsProcessor.data.orbitPositionDamping.targetValue, ref CameraSettingsProcessor.original.cameraOffsetOffset.targetValue);
|
||||||
Vector3ValueGroup.UpdateValue(orbitTargetOffset, ref CameraSettingsProcessor.data.orbitTargetOffset.value, ref CameraSettingsProcessor.original.cameraOffsetOffset.value);
|
Vector3ValueGroup.UpdateValue(orbitTargetOffset, ref CameraSettingsProcessor.data.orbitTargetOffset.targetValue, ref CameraSettingsProcessor.original.cameraOffsetOffset.targetValue);
|
||||||
|
|
||||||
Vector2ValueGroup.UpdateValue(screenPosition, ref CameraSettingsProcessor.data.rotationComposerScreenPos.value, ref CameraSettingsProcessor.original.rotationComposerScreenPos.value);
|
Vector2ValueGroup.UpdateValue(screenPosition, ref CameraSettingsProcessor.data.rotationComposerScreenPos.targetValue, ref CameraSettingsProcessor.original.rotationComposerScreenPos.targetValue);
|
||||||
FloatValueGroup.UpdateValue(fieldOfView, ref CameraSettingsProcessor.data.mainFieldOfView.value, ref CameraSettingsProcessor.original.mainFieldOfView.value);
|
FloatValueGroup.UpdateValue(fieldOfView, ref CameraSettingsProcessor.data.mainFieldOfView.targetValue, ref CameraSettingsProcessor.original.mainFieldOfView.targetValue);
|
||||||
|
|
||||||
FloatValueGroup.UpdateValue(axisLookXGain, ref CameraSettingsProcessor.data.axisLookGainX.value, ref CameraSettingsProcessor.original.axisLookGainX.value);
|
FloatValueGroup.UpdateValue(axisLookXGain, ref CameraSettingsProcessor.data.axisLookGainX.targetValue, ref CameraSettingsProcessor.original.axisLookGainX.targetValue);
|
||||||
FloatValueGroup.UpdateValue(axisLookYGain, ref CameraSettingsProcessor.data.axisLookGainY.value, ref CameraSettingsProcessor.original.axisLookGainY.value);
|
FloatValueGroup.UpdateValue(axisLookYGain, ref CameraSettingsProcessor.data.axisLookGainY.targetValue, ref CameraSettingsProcessor.original.axisLookGainY.targetValue);
|
||||||
|
|
||||||
BoolValueGroup.UpdateValue(enableXAxis, ref CameraSettingsProcessor.data.axisLookEnabledX.value, ref CameraSettingsProcessor.original.axisLookEnabledX.value);
|
BoolValueGroup.UpdateValue(enableXAxis, ref CameraSettingsProcessor.data.axisLookEnabledX.targetValue, ref CameraSettingsProcessor.original.axisLookEnabledX.targetValue);
|
||||||
BoolValueGroup.UpdateValue(enableYAxis, ref CameraSettingsProcessor.data.axisLookEnabledY.value, ref CameraSettingsProcessor.original.axisLookEnabledY.value);
|
BoolValueGroup.UpdateValue(enableYAxis, ref CameraSettingsProcessor.data.axisLookEnabledY.targetValue, ref CameraSettingsProcessor.original.axisLookEnabledY.targetValue);
|
||||||
|
|
||||||
EndAction(true);
|
EndAction(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,13 +16,12 @@ namespace Reset.Core {
|
|||||||
public FloatValueGroup moveSpeedSoothing = new (newLabel: "Move Speed Smoothing");
|
public FloatValueGroup moveSpeedSoothing = new (newLabel: "Move Speed Smoothing");
|
||||||
|
|
||||||
[ParadoxNotion.Design.Header("Direction")]
|
[ParadoxNotion.Design.Header("Direction")]
|
||||||
|
|
||||||
public FloatValueGroup airDirectionDecay = new FloatValueGroup("Air Direction Decay");
|
public FloatValueGroup airDirectionDecay = new FloatValueGroup("Air Direction Decay");
|
||||||
public FloatValueGroup accelerationSmoothing = new (newLabel: "Acceleration Smoothing");
|
public FloatValueGroup accelerationSmoothing = new (newLabel: "Acceleration Smoothing");
|
||||||
public FloatValueGroup deaccelerationSmoothing = new (newLabel: "Deacceleration Smoothing");
|
public FloatValueGroup deaccelerationSmoothing = new (newLabel: "Deacceleration Smoothing");
|
||||||
// public CurveValueGroup deaccelerationCurve = new (newLabel: "Deacceleration Curve"); // Currently unused, may return
|
// public CurveValueGroup deaccelerationCurve = new (newLabel: "Deacceleration Curve"); // Currently unused, may return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Jumping
|
// Jumping
|
||||||
[ParadoxNotion.Design.Header("Jumping")]
|
[ParadoxNotion.Design.Header("Jumping")]
|
||||||
public FloatValueGroup jumpPower = new (newLabel: "Jump Power");
|
public FloatValueGroup jumpPower = new (newLabel: "Jump Power");
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ namespace Reset.Units {
|
|||||||
[SliderField(0,1)]
|
[SliderField(0,1)]
|
||||||
public float addInputPriorty;
|
public float addInputPriorty;
|
||||||
|
|
||||||
|
public FloatValueGroup directionSmoothing = new FloatValueGroup("Direction Smoothing");
|
||||||
|
|
||||||
//Use for initialization. This is called only once in the lifetime of the task.
|
//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
|
//Return null if init was successfull. Return an error string otherwise
|
||||||
protected override string OnInit() {
|
protected override string OnInit() {
|
||||||
|
|||||||
@@ -33,26 +33,18 @@ namespace Reset.Units {
|
|||||||
// ValueGroup.ChangeSmoothingEasing(jumpPower, ref agent.data.jumpPower.currentSmoothing,
|
// ValueGroup.ChangeSmoothingEasing(jumpPower, ref agent.data.jumpPower.currentSmoothing,
|
||||||
// ref agent.data.jumpPower.easing, ref agent.defaultData.jumpPower.smoothing, ref agent.defaultData.jumpPower.easing);
|
// ref agent.data.jumpPower.easing, ref agent.defaultData.jumpPower.smoothing, ref agent.defaultData.jumpPower.easing);
|
||||||
|
|
||||||
FloatValueGroup.UpdateValue(jumpPowerDecay, ref agent.data.jumpPowerDecay.value, ref agent.defaultData.jumpPowerDecay.value);
|
FloatValueGroup.UpdateValue(jumpPowerDecay, agent.data.jumpPowerDecay);
|
||||||
ValueGroup.ChangeSmoothingEasing(jumpPowerDecay, ref agent.data.jumpPowerDecay.currentSmoothing,
|
|
||||||
ref agent.data.jumpPowerDecay.easing, ref agent.defaultData.jumpPowerDecay.smoothing, ref agent.defaultData.jumpPowerDecay.easing);
|
|
||||||
|
|
||||||
// Deprecated by SetNewGravity
|
// Deprecated by SetNewGravity
|
||||||
// FloatValueGroup.UpdateValue(gravityPower, ref agent.data.gravityPower.value, ref agent.defaultData.gravityPower.value);
|
// FloatValueGroup.UpdateValue(gravityPower, ref agent.data.gravityPower.value, ref agent.defaultData.gravityPower.value);
|
||||||
// ValueGroup.ChangeSmoothingEasing(gravityPower, ref agent.data.gravityPower.currentSmoothing,
|
// ValueGroup.ChangeSmoothingEasing(gravityPower, ref agent.data.gravityPower.currentSmoothing,
|
||||||
// ref agent.data.gravityPower.easing, ref agent.defaultData.gravityPower.smoothing, ref agent.defaultData.gravityPower.easing);
|
// ref agent.data.gravityPower.easing, ref agent.defaultData.gravityPower.smoothing, ref agent.defaultData.gravityPower.easing);
|
||||||
|
|
||||||
FloatValueGroup.UpdateValue(gravityMax, ref agent.data.gravityMax.value, ref agent.defaultData.gravityMax.value);
|
FloatValueGroup.UpdateValue(gravityMax, agent.data.gravityMax);
|
||||||
ValueGroup.ChangeSmoothingEasing(gravityMax, ref agent.data.gravityMax.currentSmoothing,
|
|
||||||
ref agent.data.gravityMax.easing, ref agent.defaultData.gravityMax.smoothing, ref agent.defaultData.gravityMax.easing);
|
|
||||||
|
|
||||||
FloatValueGroup.UpdateValue(gravityAcceleration, ref agent.data.gravityAcceleration.value, ref agent.defaultData.gravityAcceleration.value);
|
FloatValueGroup.UpdateValue(gravityAcceleration, agent.data.gravityAcceleration);
|
||||||
ValueGroup.ChangeSmoothingEasing(gravityAcceleration, ref agent.data.gravityAcceleration.currentSmoothing,
|
|
||||||
ref agent.data.gravityAcceleration.easing, ref agent.defaultData.gravityAcceleration.smoothing, ref agent.defaultData.gravityAcceleration.easing);
|
|
||||||
|
|
||||||
FloatValueGroup.UpdateValue(gravityScale, ref agent.data.gravityScale.value, ref agent.defaultData.gravityScale.value);
|
FloatValueGroup.UpdateValue(gravityScale, agent.data.gravityScale);
|
||||||
ValueGroup.ChangeSmoothingEasing(gravityScale, ref agent.data.gravityScale.currentSmoothing,
|
|
||||||
ref agent.data.gravityScale.easing, ref agent.defaultData.gravityScale.smoothing, ref agent.defaultData.gravityScale.easing);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Called once per frame while the action is active.
|
//Called once per frame while the action is active.
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
using NodeCanvas.Framework;
|
using NodeCanvas.Framework;
|
||||||
using ParadoxNotion.Design;
|
using ParadoxNotion.Design;
|
||||||
|
using Reset.Core;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
|
||||||
namespace Reset.Units {
|
namespace Reset.Units {
|
||||||
|
|
||||||
[Category("Reset/Movement")]
|
[Category("Reset/Movement")]
|
||||||
public class ChangeMoveSpeedSettings : ActionTask<UnitMovementHandler> {
|
public class ChangeMoveSpeedSettings : ActionTask<UnitMovementHandler> {
|
||||||
|
[SerializeField] public FloatValueGroup moveSpeed = new (newLabel: "Move Speed");
|
||||||
|
[SerializeField] public FloatValueGroup acceleration = new (newLabel: "Acceleration");
|
||||||
|
[SerializeField] public FloatValueGroup deacceleration = new (newLabel: "Deacceleration");
|
||||||
|
|
||||||
//Use for initialization. This is called only once in the lifetime of the task.
|
//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
|
//Return null if init was successfull. Return an error string otherwise
|
||||||
@@ -17,6 +22,19 @@ namespace Reset.Units {
|
|||||||
//Call EndAction() to mark the action as finished, either in success or failure.
|
//Call EndAction() to mark the action as finished, either in success or failure.
|
||||||
//EndAction can be called from anywhere.
|
//EndAction can be called from anywhere.
|
||||||
protected override void OnExecute() {
|
protected override void OnExecute() {
|
||||||
|
FloatValueGroup.UpdateValue(moveSpeed, ref agent.data.moveSpeed.targetValue, ref agent.data.moveSpeed.defaultValue);
|
||||||
|
ValueGroup.ChangeSmoothingEasing(moveSpeed, ref agent.data.moveSpeed.targetSmoothing,
|
||||||
|
ref agent.data.moveSpeed.targetEasing, ref agent.data.moveSpeed.defaultSmoothing, ref agent.data.moveSpeed.defaultEasing);
|
||||||
|
|
||||||
|
FloatValueGroup.UpdateValue(acceleration, ref agent.data.acceleration.targetValue, ref agent.data.acceleration.defaultValue);
|
||||||
|
ValueGroup.ChangeSmoothingEasing(acceleration, ref agent.data.acceleration.targetSmoothing,
|
||||||
|
ref agent.data.acceleration.targetEasing, ref agent.data.acceleration.defaultSmoothing, ref agent.data.acceleration.defaultEasing);
|
||||||
|
|
||||||
|
FloatValueGroup.UpdateValue(deacceleration, ref agent.data.deacceleration.targetValue, ref agent.data.deacceleration.defaultValue);
|
||||||
|
ValueGroup.ChangeSmoothingEasing(deacceleration, ref agent.data.deacceleration.targetSmoothing,
|
||||||
|
ref agent.data.deacceleration.targetEasing, ref agent.data.deacceleration.defaultSmoothing, ref agent.data.deacceleration.defaultEasing);
|
||||||
|
|
||||||
|
|
||||||
EndAction(true);
|
EndAction(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using System;
|
|||||||
using NodeCanvas.Framework;
|
using NodeCanvas.Framework;
|
||||||
using ParadoxNotion.Design;
|
using ParadoxNotion.Design;
|
||||||
using Reset.Movement;
|
using Reset.Movement;
|
||||||
|
using Reset.Units;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace NodeCanvas.Tasks.Actions {
|
namespace NodeCanvas.Tasks.Actions {
|
||||||
|
|||||||
@@ -384,7 +384,25 @@ namespace Reset.Core{
|
|||||||
Easing = new BBParameter<float>().value = 0f;
|
Easing = new BBParameter<float>().value = 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void UpdateValue(FloatValueGroup valueGroup, SettingValue<float> settingValue){
|
||||||
|
switch (valueGroup.changeValue.value) {
|
||||||
|
case ValueChangeAction.NewValue:
|
||||||
|
settingValue.Value = valueGroup.value.value;
|
||||||
|
break;
|
||||||
|
case ValueChangeAction.ResetValue:
|
||||||
|
settingValue.Value = settingValue.defaultValue;
|
||||||
|
break;
|
||||||
|
case ValueChangeAction.RelativeValue:
|
||||||
|
settingValue.Value += valueGroup.value.value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ValueGroup.ChangeSmoothingEasing(valueGroup, ref settingValue.targetSmoothing,
|
||||||
|
ref settingValue.targetEasing, ref settingValue.defaultEasing, ref settingValue.defaultSmoothing);
|
||||||
|
}
|
||||||
|
|
||||||
public static void UpdateValue(FloatValueGroup valueGroup, ref float targetProperty, ref float defaultProperty){
|
public static void UpdateValue(FloatValueGroup valueGroup, ref float targetProperty, ref float defaultProperty){
|
||||||
|
Debug.LogWarning("Deprecated call of UpdateValue(). Use the new one with only two arguments!");
|
||||||
switch (valueGroup.changeValue.value) {
|
switch (valueGroup.changeValue.value) {
|
||||||
case ValueChangeAction.NewValue:
|
case ValueChangeAction.NewValue:
|
||||||
targetProperty = valueGroup.value.value;
|
targetProperty = valueGroup.value.value;
|
||||||
|
|||||||
@@ -69,111 +69,77 @@ public class CameraSettingsProcessor : MonoBehaviour{
|
|||||||
axisCont = mainCamera.GetComponent<CinemachineInputAxisController>();
|
axisCont = mainCamera.GetComponent<CinemachineInputAxisController>();
|
||||||
|
|
||||||
// Initialize camera settings values from current values
|
// Initialize camera settings values from current values
|
||||||
data.mainFieldOfView.value = main.Lens.FieldOfView;
|
data.mainFieldOfView.targetValue = main.Lens.FieldOfView;
|
||||||
|
|
||||||
data.orbitPositionDamping.value = orbit.TrackerSettings.PositionDamping;
|
data.orbitPositionDamping.targetValue = orbit.TrackerSettings.PositionDamping;
|
||||||
data.orbitTargetOffset.value = orbit.TargetOffset;
|
data.orbitTargetOffset.targetValue = orbit.TargetOffset;
|
||||||
|
|
||||||
data.axisLookEnabledX.value = axisCont.Controllers[0].Enabled;
|
data.axisLookEnabledX.targetValue = axisCont.Controllers[0].Enabled;
|
||||||
data.axisLookEnabledY.value = axisCont.Controllers[1].Enabled;
|
data.axisLookEnabledY.targetValue = axisCont.Controllers[1].Enabled;
|
||||||
|
|
||||||
data.axisLookGainX.value = axisCont.Controllers[0].Input.Gain;
|
data.axisLookGainX.targetValue = axisCont.Controllers[0].Input.Gain;
|
||||||
data.axisLookGainY.value = axisCont.Controllers[1].Input.Gain;
|
data.axisLookGainY.targetValue = axisCont.Controllers[1].Input.Gain;
|
||||||
|
|
||||||
data.orbitFollowTopHeight.value = orbit.Orbits.Top.Height;
|
data.orbitFollowTopHeight.targetValue = orbit.Orbits.Top.Height;
|
||||||
data.orbitFollowTopRadius.value = orbit.Orbits.Top.Radius;
|
data.orbitFollowTopRadius.targetValue = orbit.Orbits.Top.Radius;
|
||||||
data.orbitFollowCenterHeight.value = orbit.Orbits.Center.Height;
|
data.orbitFollowCenterHeight.targetValue = orbit.Orbits.Center.Height;
|
||||||
data.orbitFollowCenterRadius.value = orbit.Orbits.Center.Radius;
|
data.orbitFollowCenterRadius.targetValue = orbit.Orbits.Center.Radius;
|
||||||
data.orbitFollowBottomHeight.value = orbit.Orbits.Bottom.Height;
|
data.orbitFollowBottomHeight.targetValue = orbit.Orbits.Bottom.Height;
|
||||||
data.orbitFollowBottomRadius.value = orbit.Orbits.Bottom.Radius;
|
data.orbitFollowBottomRadius.targetValue = orbit.Orbits.Bottom.Radius;
|
||||||
|
|
||||||
data.rotationComposerScreenPos.value = rotComp.Composition.ScreenPosition;
|
data.rotationComposerScreenPos.targetValue = rotComp.Composition.ScreenPosition;
|
||||||
data.cameraOffsetOffset.value = offset.Offset;
|
data.cameraOffsetOffset.targetValue = offset.Offset;
|
||||||
|
|
||||||
// And copy to the original
|
// And copy to the original
|
||||||
original = (CameraSettingData)data.Clone();
|
original = (CameraSettingData)data.Clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update(){
|
void Update(){
|
||||||
EaseToNewSmoothingValues();
|
// EaseToNewSmoothingValues();
|
||||||
ProcessCameraValues();
|
// ProcessCameraValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EaseToNewSmoothingValues(){
|
void EaseToNewSmoothingValues(){
|
||||||
data.mainFieldOfView.currentSmoothing = Mathf.MoveTowards(data.mainFieldOfView.currentSmoothing, data.mainFieldOfView.smoothing, data.mainFieldOfView.easing * Time.deltaTime);
|
data.mainFieldOfView.SmoothAndEase();
|
||||||
|
|
||||||
data.orbitPositionDamping.currentSmoothing = Mathf.MoveTowards(data.orbitPositionDamping.currentSmoothing, data.orbitPositionDamping.smoothing, easing.orbitPositionDamping.easing * Time.deltaTime);
|
data.orbitPositionDamping.SmoothAndEase();
|
||||||
data.orbitTargetOffset.currentSmoothing = Mathf.MoveTowards(data.mainFieldOfView.currentSmoothing, data.mainFieldOfView.smoothing, easing.mainFieldOfView.easing * Time.deltaTime);
|
data.orbitTargetOffset.SmoothAndEase();
|
||||||
|
|
||||||
data.axisLookGainX.currentSmoothing = Mathf.MoveTowards(data.mainFieldOfView.currentSmoothing, data.mainFieldOfView.smoothing, easing.mainFieldOfView.easing * Time.deltaTime);
|
data.axisLookGainX.SmoothAndEase();
|
||||||
data.axisLookGainY.currentSmoothing = Mathf.MoveTowards(data.mainFieldOfView.currentSmoothing, data.mainFieldOfView.smoothing, easing.mainFieldOfView.easing * Time.deltaTime);
|
data.axisLookGainY.SmoothAndEase();
|
||||||
|
|
||||||
data.orbitFollowTopHeight.currentSmoothing = Mathf.MoveTowards(data.mainFieldOfView.currentSmoothing, data.mainFieldOfView.smoothing, easing.mainFieldOfView.easing * Time.deltaTime);
|
data.orbitFollowTopHeight.SmoothAndEase();
|
||||||
data.orbitFollowTopRadius.currentSmoothing = Mathf.MoveTowards(data.mainFieldOfView.currentSmoothing, data.mainFieldOfView.smoothing, easing.mainFieldOfView.easing * Time.deltaTime);
|
data.orbitFollowTopRadius.SmoothAndEase();
|
||||||
data.orbitFollowCenterHeight.currentSmoothing = Mathf.MoveTowards(data.mainFieldOfView.currentSmoothing, data.mainFieldOfView.smoothing, easing.mainFieldOfView.easing * Time.deltaTime);
|
data.orbitFollowCenterHeight.SmoothAndEase();
|
||||||
data.orbitFollowCenterRadius.currentSmoothing = Mathf.MoveTowards(data.mainFieldOfView.currentSmoothing, data.mainFieldOfView.smoothing, easing.mainFieldOfView.easing * Time.deltaTime);
|
data.orbitFollowCenterRadius.SmoothAndEase();
|
||||||
data.orbitFollowBottomHeight.currentSmoothing = Mathf.MoveTowards(data.mainFieldOfView.currentSmoothing, data.mainFieldOfView.smoothing, easing.mainFieldOfView.easing * Time.deltaTime);
|
data.orbitFollowBottomHeight.SmoothAndEase();
|
||||||
data.orbitFollowBottomRadius.currentSmoothing = Mathf.MoveTowards(data.mainFieldOfView.currentSmoothing, data.mainFieldOfView.smoothing, easing.mainFieldOfView.easing * Time.deltaTime);
|
data.orbitFollowBottomRadius.SmoothAndEase();
|
||||||
|
|
||||||
data.rotationComposerScreenPos.currentSmoothing = Mathf.MoveTowards(data.mainFieldOfView.currentSmoothing, data.mainFieldOfView.smoothing, easing.mainFieldOfView.easing * Time.deltaTime);
|
data.rotationComposerScreenPos.SmoothAndEase();
|
||||||
data.cameraOffsetOffset.currentSmoothing = Mathf.MoveTowards(data.mainFieldOfView.currentSmoothing, data.mainFieldOfView.smoothing, easing.mainFieldOfView.easing * Time.deltaTime);
|
data.cameraOffsetOffset.SmoothAndEase();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessCameraValues(){
|
void ProcessCameraValues(){
|
||||||
main.Lens.FieldOfView = Mathf.SmoothDamp(main.Lens.FieldOfView,
|
main.Lens.FieldOfView = data.mainFieldOfView.Value;
|
||||||
data.mainFieldOfView.value, ref data.mainFieldOfView.refVel,
|
|
||||||
data.mainFieldOfView.smoothing);
|
|
||||||
|
|
||||||
axisCont.Controllers[0].Enabled = data.axisLookEnabledX.value;
|
axisCont.Controllers[0].Enabled = data.axisLookEnabledX.Value;
|
||||||
|
axisCont.Controllers[1].Enabled = data.axisLookEnabledY.Value;
|
||||||
|
|
||||||
axisCont.Controllers[1].Enabled = data.axisLookEnabledY.value;
|
axisCont.Controllers[0].Input.Gain = data.axisLookGainX.Value;
|
||||||
|
axisCont.Controllers[1].Input.Gain = data.axisLookGainY.Value;
|
||||||
|
|
||||||
axisCont.Controllers[0].Input.Gain = Mathf.SmoothDamp(axisCont.Controllers[0].Input.Gain,
|
orbit.TrackerSettings.PositionDamping = data.orbitPositionDamping.Value;
|
||||||
data.axisLookGainX.value, ref data.axisLookGainX.refVel,
|
orbit.TargetOffset = data.orbitTargetOffset.Value;
|
||||||
data.axisLookGainX.smoothing);
|
|
||||||
|
|
||||||
axisCont.Controllers[1].Input.Gain = Mathf.SmoothDamp(axisCont.Controllers[1].Input.Gain,
|
orbit.Orbits.Top.Height = data.orbitFollowTopHeight.Value;
|
||||||
data.axisLookGainY.value, ref data.axisLookGainY.refVel,
|
orbit.Orbits.Top.Radius = data.orbitFollowTopRadius.Value;
|
||||||
data.axisLookGainY.smoothing);
|
orbit.Orbits.Center.Height = data.orbitFollowCenterHeight.Value;
|
||||||
|
orbit.Orbits.Center.Radius = data.orbitFollowCenterRadius.Value;
|
||||||
|
orbit.Orbits.Bottom.Height = data.orbitFollowBottomHeight.Value;
|
||||||
|
orbit.Orbits.Bottom.Radius = data.orbitFollowBottomRadius.Value;
|
||||||
|
|
||||||
orbit.TargetOffset = Vector3.SmoothDamp(orbit.TargetOffset,
|
rotComp.Composition.ScreenPosition = data.rotationComposerScreenPos.Value;
|
||||||
data.orbitTargetOffset.value, ref data.orbitTargetOffset.refVel,
|
|
||||||
data.orbitTargetOffset.smoothing);
|
|
||||||
|
|
||||||
orbit.TrackerSettings.PositionDamping = Vector3.SmoothDamp(orbit.TrackerSettings.PositionDamping,
|
offset.Offset = data.cameraOffsetOffset.Value;
|
||||||
data.orbitPositionDamping.value, ref data.orbitPositionDamping.refVel,
|
|
||||||
data.orbitPositionDamping.smoothing);
|
|
||||||
|
|
||||||
orbit.Orbits.Top.Height = Mathf.SmoothDamp(orbit.Orbits.Top.Height,
|
|
||||||
data.orbitFollowTopHeight.value, ref data.orbitFollowTopHeight.refVel,
|
|
||||||
data.orbitFollowTopHeight.smoothing);
|
|
||||||
|
|
||||||
orbit.Orbits.Top.Radius = Mathf.SmoothDamp(orbit.Orbits.Top.Radius,
|
|
||||||
data.orbitFollowTopRadius.value, ref data.orbitFollowTopRadius.refVel,
|
|
||||||
data.orbitFollowTopRadius.smoothing);
|
|
||||||
|
|
||||||
orbit.Orbits.Center.Height = Mathf.SmoothDamp(orbit.Orbits.Center.Height,
|
|
||||||
data.orbitFollowCenterHeight.value, ref data.orbitFollowCenterHeight.refVel,
|
|
||||||
data.orbitFollowCenterHeight.smoothing);
|
|
||||||
|
|
||||||
orbit.Orbits.Center.Radius = Mathf.SmoothDamp(orbit.Orbits.Center.Radius,
|
|
||||||
data.orbitFollowCenterRadius.value, ref data.orbitFollowCenterRadius.refVel,
|
|
||||||
data.orbitFollowCenterRadius.smoothing);
|
|
||||||
|
|
||||||
orbit.Orbits.Bottom.Height = Mathf.SmoothDamp(orbit.Orbits.Bottom.Height,
|
|
||||||
data.orbitFollowBottomHeight.value, ref data.orbitFollowBottomHeight.refVel,
|
|
||||||
data.orbitFollowBottomHeight.smoothing);
|
|
||||||
|
|
||||||
orbit.Orbits.Bottom.Radius = Mathf.SmoothDamp(orbit.Orbits.Bottom.Radius,
|
|
||||||
data.orbitFollowBottomRadius.value, ref data.orbitFollowBottomRadius.refVel,
|
|
||||||
data.orbitFollowBottomRadius.smoothing);
|
|
||||||
|
|
||||||
rotComp.Composition.ScreenPosition = Vector2.SmoothDamp(rotComp.Composition.ScreenPosition,
|
|
||||||
data.rotationComposerScreenPos.value, ref data.rotationComposerScreenPos.refVel,
|
|
||||||
data.rotationComposerScreenPos.smoothing);
|
|
||||||
|
|
||||||
offset.Offset = Vector3.SmoothDamp(offset.Offset,
|
|
||||||
data.cameraOffsetOffset.value, ref data.cameraOffsetOffset.refVel,
|
|
||||||
data.cameraOffsetOffset.smoothing);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
10
Assets/Scripts/Player/PlayerFacingDirection.cs
Normal file
10
Assets/Scripts/Player/PlayerFacingDirection.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
namespace Reset.Units{
|
||||||
|
public enum PlayerFacingDirection{
|
||||||
|
TowardsTarget = 0,
|
||||||
|
MatchForward,
|
||||||
|
MatchCamera,
|
||||||
|
Static,
|
||||||
|
Momentum,
|
||||||
|
SpecifiedDirection
|
||||||
|
}
|
||||||
|
}
|
||||||
3
Assets/Scripts/Player/PlayerFacingDirection.cs.meta
Normal file
3
Assets/Scripts/Player/PlayerFacingDirection.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 81d909774c8e4b66be6e96fd13f9bff4
|
||||||
|
timeCreated: 1758478092
|
||||||
37
Assets/Scripts/Player/ResolvedMovement.cs
Normal file
37
Assets/Scripts/Player/ResolvedMovement.cs
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
using Sirenix.OdinInspector;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Reset.Units{
|
||||||
|
public class ResolvedMovement{
|
||||||
|
public struct MoveDirection{
|
||||||
|
private Transform owner;
|
||||||
|
|
||||||
|
private Vector2 _moveDir; // Always local
|
||||||
|
|
||||||
|
public Vector2 World{
|
||||||
|
get => owner.TransformDirection(_moveDir);
|
||||||
|
set{
|
||||||
|
_moveDir = owner.InverseTransformDirection(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector2 Local{
|
||||||
|
get => _moveDir;
|
||||||
|
set {
|
||||||
|
_moveDir = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public MoveDirection(Transform ownerTransform){
|
||||||
|
owner = ownerTransform;
|
||||||
|
_moveDir = Vector2.zero;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[ShowInInspector] public MoveDirection moveDirection;
|
||||||
|
public float moveSpeed;
|
||||||
|
public Quaternion rotation;
|
||||||
|
public float rotationSpeed;
|
||||||
|
public float gravity;
|
||||||
|
}
|
||||||
|
}
|
||||||
3
Assets/Scripts/Player/ResolvedMovement.cs.meta
Normal file
3
Assets/Scripts/Player/ResolvedMovement.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d663059052094322bff98f9ed2839fd9
|
||||||
|
timeCreated: 1758478092
|
||||||
@@ -1,24 +1,80 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.Serialization;
|
||||||
|
|
||||||
|
public interface IResettableSettingValue{
|
||||||
|
public abstract void SmoothAndEase();
|
||||||
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public struct SettingValue<T>{
|
public struct SettingValue<T> : IResettableSettingValue{
|
||||||
public T value;
|
public T targetValue;
|
||||||
public float smoothing; // Smoothing changes how fast value is changed.
|
public T currentValue;
|
||||||
public float easing; // Easing changes how fast smoothing is changed, when given a new value.
|
public T refVel;
|
||||||
|
|
||||||
public float currentSmoothing; // Actively eased and accessed value
|
public float targetSmoothing; // Smoothing changes how fast the value is changed.
|
||||||
public float currentValue; // Actively smoothed and accessed value
|
public float targetEasing; // Easing changes how fast smoothing is changed, when given a new value.
|
||||||
|
|
||||||
|
public T Value{
|
||||||
|
get => currentValue;
|
||||||
|
set => targetValue = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private float currentSmoothing;
|
||||||
|
|
||||||
|
public T defaultValue;
|
||||||
|
public float defaultSmoothing;
|
||||||
|
public float defaultEasing;
|
||||||
|
|
||||||
|
private float refVelFloat; // For use with SmoothDamp
|
||||||
|
private Vector3 refVelV3; // For use with SmoothDamp
|
||||||
|
private Vector2 refVelV2; // For use with SmoothDamp
|
||||||
|
|
||||||
public T refVel; // For use with SmoothDamp
|
|
||||||
|
|
||||||
public SettingValue(T initValue, float defaultEasing = 2f, float defaultSmoothing = 1f){
|
public SettingValue(T initValue, float defaultEasing = 2f, float defaultSmoothing = 1f){
|
||||||
value = initValue;
|
targetValue = initValue;
|
||||||
|
|
||||||
easing = defaultEasing;
|
this.defaultSmoothing = defaultSmoothing;
|
||||||
value = default;
|
this.defaultEasing = defaultEasing;
|
||||||
smoothing = defaultSmoothing;
|
|
||||||
currentSmoothing = 0;
|
targetEasing = defaultEasing;
|
||||||
currentValue = 0;
|
targetSmoothing = defaultSmoothing;
|
||||||
|
|
||||||
|
currentSmoothing = targetSmoothing;
|
||||||
|
currentValue = targetValue;
|
||||||
|
|
||||||
|
refVelFloat = 0;
|
||||||
|
refVelV3 = default;
|
||||||
|
refVelV2 = default;
|
||||||
refVel = default;
|
refVel = default;
|
||||||
|
|
||||||
|
defaultValue = initValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SmoothAndEase(){
|
||||||
|
Debug.Log("Worked!");
|
||||||
|
return;
|
||||||
|
|
||||||
|
currentSmoothing = Mathf.MoveTowards(currentSmoothing, targetSmoothing, targetEasing * 1f * Time.deltaTime);
|
||||||
|
|
||||||
|
if (typeof(T) == typeof(float)) {
|
||||||
|
currentValue = (T)(object)Mathf.SmoothDamp((float)(object)currentValue, (float)(object)targetValue, ref refVelFloat, currentSmoothing * Time.deltaTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof(T) == typeof(Vector2)) {
|
||||||
|
currentValue = (T)(object)Vector2.SmoothDamp((Vector2)(object)currentValue, (Vector2)(object)targetValue, ref refVelV2, currentSmoothing * Time.deltaTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof(T) == typeof(Vector3)) {
|
||||||
|
currentValue = (T)(object)Vector3.SmoothDamp((Vector3)(object)currentValue, (Vector3)(object)targetValue, ref refVelV3, currentSmoothing * Time.deltaTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof(T) == typeof(Vector4) || typeof(T) == typeof(Quaternion)) {
|
||||||
|
// I have... zero clue if this will work. There is no Vector4 or Quaternion SmoothDamp
|
||||||
|
Vector3 v3value = Vector3.SmoothDamp((Vector4)(object)currentValue, (Vector4)(object)targetValue, ref refVelV3, currentSmoothing * Time.deltaTime);
|
||||||
|
float v4value = Mathf.SmoothDamp(((Vector4)(object)currentValue).z, ((Vector4)(object)targetValue).z, ref refVelFloat, currentSmoothing * Time.deltaTime);
|
||||||
|
|
||||||
|
currentValue = (T)(object)new Vector4(v3value.x, v3value.y, v3value.z, v4value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
55
Assets/Scripts/Player/UnitMovementData.cs
Normal file
55
Assets/Scripts/Player/UnitMovementData.cs
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using ParadoxNotion.Design;
|
||||||
|
using Sirenix.OdinInspector;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Reset.Units{
|
||||||
|
[Serializable]
|
||||||
|
public class UnitMovementData : ICloneable{
|
||||||
|
// Movement Direction
|
||||||
|
public SettingValue<Vector2> moveSmoothing = new SettingValue<Vector2>(new Vector2(.5f, .5f));
|
||||||
|
public SettingValue<float> acceleration = new SettingValue<float>(5f);
|
||||||
|
public SettingValue<float> deacceleration = new SettingValue<float>(5f);
|
||||||
|
|
||||||
|
[SliderField(0,1)]
|
||||||
|
public SettingValue<float> airDirectionDecay = new SettingValue<float>(1f); // TODO: Check default value
|
||||||
|
|
||||||
|
// Move Speed
|
||||||
|
public SettingValue<float> softening = new SettingValue<float>(1f, defaultSmoothing: 1f);
|
||||||
|
public SettingValue<float> moveSpeed = new SettingValue<float>(15f, defaultSmoothing: 10f);
|
||||||
|
|
||||||
|
// Jumping
|
||||||
|
[ShowInInspector] public SettingValue<float> jumpPower = new SettingValue<float>(0f);
|
||||||
|
public SettingValue<float> jumpPowerDecay = new SettingValue<float>(3f); // TODO: Check default value
|
||||||
|
|
||||||
|
// Gravity
|
||||||
|
[ShowInInspector] public SettingValue<float> gravityPower = new SettingValue<float>(1f);
|
||||||
|
public SettingValue<float> gravityMax = new SettingValue<float>(8f);
|
||||||
|
public SettingValue<float> gravityAcceleration = new SettingValue<float>(1f);
|
||||||
|
public SettingValue<float> gravityScale = new SettingValue<float>(1f);
|
||||||
|
|
||||||
|
// Rotation
|
||||||
|
[ShowInInspector, SerializeReference] public Enum rotateFacing;
|
||||||
|
public SettingValue<float> rotationSpeed = new SettingValue<float>(5f);
|
||||||
|
public SettingValue<float> rotationInputBlending = new SettingValue<float>(.3f);
|
||||||
|
|
||||||
|
public object Clone(){
|
||||||
|
return MemberwiseClone();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<IResettableSettingValue> GetAllSettings(){
|
||||||
|
var outputList = new List<IResettableSettingValue>();
|
||||||
|
|
||||||
|
IResettableSettingValue[] test = new[]{
|
||||||
|
moveSmoothing as IResettableSettingValue,
|
||||||
|
};
|
||||||
|
|
||||||
|
test[0].SmoothAndEase();
|
||||||
|
|
||||||
|
outputList.AddRange(test);
|
||||||
|
|
||||||
|
return outputList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
3
Assets/Scripts/Player/UnitMovementData.cs.meta
Normal file
3
Assets/Scripts/Player/UnitMovementData.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7f5d86c96bcf450b888da32d1cf253e7
|
||||||
|
timeCreated: 1758478092
|
||||||
@@ -1,101 +1,12 @@
|
|||||||
using System;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using ParadoxNotion.Design;
|
|
||||||
using PlasticPipe.PlasticProtocol.Messages;
|
|
||||||
using Reset.Core.Tools;
|
using Reset.Core.Tools;
|
||||||
using Sirenix.OdinInspector;
|
using Sirenix.OdinInspector;
|
||||||
|
|
||||||
public enum PlayerFacingDirection{
|
|
||||||
TowardsTarget = 0,
|
|
||||||
MatchForward,
|
|
||||||
MatchCamera,
|
|
||||||
Static,
|
|
||||||
Momentum,
|
|
||||||
SpecifiedDirection
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Reset.Units{
|
namespace Reset.Units{
|
||||||
// public interface IBuffSource{ - Unused good idea?
|
|
||||||
// public Object sourceObject();
|
|
||||||
// public
|
|
||||||
// }
|
|
||||||
|
|
||||||
[Serializable]
|
|
||||||
public class UnitMovementData : ICloneable{
|
|
||||||
// Movement Direction
|
|
||||||
public SettingValue<Vector2> moveSmoothing = new SettingValue<Vector2>(new Vector2(.5f, .5f));
|
|
||||||
public SettingValue<float> acceleration = new SettingValue<float>(5f);
|
|
||||||
public SettingValue<float> deaccerlation = new SettingValue<float>(5f);
|
|
||||||
|
|
||||||
[SliderField(0,1)]
|
|
||||||
public SettingValue<float> airDirectionDecay = new SettingValue<float>(1f); // TODO: Check default value
|
|
||||||
|
|
||||||
// Move Speed
|
|
||||||
public SettingValue<float> moveSpeed = new SettingValue<float>(15f, defaultSmoothing: 10f);
|
|
||||||
|
|
||||||
// Jumping
|
|
||||||
[ShowInInspector] public SettingValue<float> jumpPower = new SettingValue<float>(0f);
|
|
||||||
public SettingValue<float> jumpPowerDecay = new SettingValue<float>(3f); // TODO: Check default value
|
|
||||||
|
|
||||||
// Gravity
|
|
||||||
[ShowInInspector] public SettingValue<float> gravityPower = new SettingValue<float>(1f);
|
|
||||||
public SettingValue<float> gravityMax = new SettingValue<float>(8f);
|
|
||||||
public SettingValue<float> gravityAcceleration = new SettingValue<float>(1f);
|
|
||||||
public SettingValue<float> gravityScale = new SettingValue<float>(1f);
|
|
||||||
|
|
||||||
// Rotation
|
|
||||||
[ShowInInspector, SerializeReference] public Enum rotateFacing;
|
|
||||||
public SettingValue<float> rotationSpeed = new SettingValue<float>(5f);
|
|
||||||
public SettingValue<float> rotationInputBlending = new SettingValue<float>(.3f);
|
|
||||||
|
|
||||||
public object Clone(){
|
|
||||||
return MemberwiseClone();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ResolvedMovement{
|
|
||||||
[ShowInInspector] public UnitMovementHandler.MoveDirection moveDirection;
|
|
||||||
public float moveSpeed;
|
|
||||||
public Quaternion rotation;
|
|
||||||
public float rotationSpeed;
|
|
||||||
public float gravity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class UnitMovementHandler : MonoBehaviour{
|
public class UnitMovementHandler : MonoBehaviour{
|
||||||
public struct MoveDirection{
|
|
||||||
private Transform owner;
|
|
||||||
|
|
||||||
private Vector2 _moveDir; // Always local
|
|
||||||
|
|
||||||
public Vector2 World{
|
|
||||||
get => owner.TransformDirection(_moveDir);
|
|
||||||
set{
|
|
||||||
_moveDir = owner.InverseTransformDirection(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vector2 Local{
|
|
||||||
get => _moveDir;
|
|
||||||
set {
|
|
||||||
_moveDir = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public MoveDirection(Transform ownerTransform){
|
|
||||||
owner = ownerTransform;
|
|
||||||
_moveDir = Vector2.zero;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[ShowInInspector]
|
[ShowInInspector]
|
||||||
public ResolvedMovement resolvedMovement;
|
public ResolvedMovement resolvedMovement;
|
||||||
|
|
||||||
// class MovementFloatModifier{
|
|
||||||
// // IBuffSource source
|
|
||||||
// public float value;
|
|
||||||
// }
|
|
||||||
|
|
||||||
//
|
|
||||||
[FoldoutGroup("Final Values"), ShowInInspector, ReadOnly] private float outputSpeed;
|
[FoldoutGroup("Final Values"), ShowInInspector, ReadOnly] private float outputSpeed;
|
||||||
[FoldoutGroup("Final Values"), ShowInInspector, ReadOnly] private float additionalSpeed;
|
[FoldoutGroup("Final Values"), ShowInInspector, ReadOnly] private float additionalSpeed;
|
||||||
[FoldoutGroup("Final Values"), ShowInInspector, ReadOnly] public Vector3 outputMoveDirection;
|
[FoldoutGroup("Final Values"), ShowInInspector, ReadOnly] public Vector3 outputMoveDirection;
|
||||||
@@ -104,7 +15,7 @@ namespace Reset.Units{
|
|||||||
[FoldoutGroup("Final Values"), ShowInInspector, ReadOnly] private Quaternion specifiedRotation;
|
[FoldoutGroup("Final Values"), ShowInInspector, ReadOnly] private Quaternion specifiedRotation;
|
||||||
[FoldoutGroup("Final Values"), ShowInInspector, ReadOnly] private float outputRotationSpeed;
|
[FoldoutGroup("Final Values"), ShowInInspector, ReadOnly] private float outputRotationSpeed;
|
||||||
|
|
||||||
// Lerps
|
// Smoothing Values
|
||||||
private float directionChangeDotLerp;
|
private float directionChangeDotLerp;
|
||||||
private Vector3 moveSmoothVelocityRef;
|
private Vector3 moveSmoothVelocityRef;
|
||||||
private float gravitySmoothVelocityRef;
|
private float gravitySmoothVelocityRef;
|
||||||
@@ -116,12 +27,7 @@ namespace Reset.Units{
|
|||||||
|
|
||||||
// Movement Data
|
// Movement Data
|
||||||
[ShowInInspector, PropertyOrder(2)] public UnitMovementData data = new();
|
[ShowInInspector, PropertyOrder(2)] public UnitMovementData data = new();
|
||||||
[ShowInInspector, PropertyOrder(2)] public UnitMovementData smoothing = new();
|
|
||||||
[ShowInInspector, PropertyOrder(2)] public UnitMovementData easing = new();
|
|
||||||
|
|
||||||
[HideInInspector] public UnitMovementData defaultData;
|
|
||||||
[HideInInspector] public UnitMovementData defaultSmoothing;
|
|
||||||
[HideInInspector] public UnitMovementData defaultEasing;
|
|
||||||
|
|
||||||
void Awake(){
|
void Awake(){
|
||||||
controller = GetComponent<CharacterController>();
|
controller = GetComponent<CharacterController>();
|
||||||
@@ -130,12 +36,8 @@ namespace Reset.Units{
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Start(){
|
void Start(){
|
||||||
defaultData = (UnitMovementData)data.Clone();
|
|
||||||
defaultSmoothing = (UnitMovementData)smoothing.Clone();
|
|
||||||
defaultEasing = (UnitMovementData)easing.Clone();
|
|
||||||
|
|
||||||
resolvedMovement = new ResolvedMovement();
|
resolvedMovement = new ResolvedMovement();
|
||||||
resolvedMovement.moveDirection = new MoveDirection(transform);
|
resolvedMovement.moveDirection = new ResolvedMovement.MoveDirection(transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update(){
|
void Update(){
|
||||||
@@ -188,7 +90,7 @@ namespace Reset.Units{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
outputSpeed = Mathf.Lerp(outputSpeed, Mathf.Max(data.moveSpeed.value, speed), priority);
|
outputSpeed = Mathf.Lerp(outputSpeed, Mathf.Max(data.moveSpeed.Value, speed), priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setting absolute to true will cause the current gravity to snap to the new gravity value.
|
// Setting absolute to true will cause the current gravity to snap to the new gravity value.
|
||||||
@@ -228,53 +130,47 @@ namespace Reset.Units{
|
|||||||
|
|
||||||
// Smooth movement. Use deaccel smoothing if the input magnitude is lower, and accel smoothing if it's higher
|
// Smooth movement. Use deaccel smoothing if the input magnitude is lower, and accel smoothing if it's higher
|
||||||
// Also checks when grounded to only use Slerp on the ground
|
// Also checks when grounded to only use Slerp on the ground
|
||||||
if (targetDirection.magnitude > currentDirection.magnitude) {
|
|
||||||
if (controller.isGrounded){
|
if (controller.isGrounded){
|
||||||
slerpedValue = Vector3.Slerp(currentDirection, targetDirection, data.acceleration.value * Time.deltaTime); // This used to be a slerp. If rotational movement broke this is why
|
slerpedValue = Vector3.Slerp(currentDirection, targetDirection, data.softening.Value * Time.deltaTime); // This used to be a slerp. If rotational movement broke this is why
|
||||||
|
lerpedValue = Vector2.Lerp(currentDirection, targetDirection, data.softening.Value * Time.deltaTime);
|
||||||
|
|
||||||
// slerpedValue = Quaternion.AngleAxis(30, Vector3.up) * slerpedValue;
|
newDirection = Vector2.Lerp(slerpedValue, lerpedValue, directionChangeDotLerp);
|
||||||
lerpedValue = Vector2.Lerp(currentDirection, targetDirection,data.acceleration.value * Time.deltaTime);
|
|
||||||
|
|
||||||
newDirection = Vector2.Lerp(slerpedValue, slerpedValue, directionChangeDotLerp);
|
|
||||||
// newDirection = slerpedValue;
|
|
||||||
} else {
|
} else {
|
||||||
newDirection = Vector2.Lerp(currentDirection, targetDirection, data.acceleration.value * Time.deltaTime);
|
newDirection = Vector2.Lerp(currentDirection, targetDirection, data.softening.Value * data.airDirectionDecay.Value * Time.deltaTime);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (controller.isGrounded){
|
|
||||||
slerpedValue = Vector3.Slerp(currentDirection, targetDirection, data.deaccerlation.value * Time.deltaTime); // This used to be a slerp. If rotational movement broke this is why
|
|
||||||
lerpedValue = Vector2.Lerp(currentDirection, targetDirection, data.deaccerlation.value * Time.deltaTime);
|
|
||||||
|
|
||||||
newDirection = Vector2.Lerp(lerpedValue, slerpedValue, directionChangeDotLerp);
|
|
||||||
} else {
|
|
||||||
newDirection = Vector2.Lerp(currentDirection, targetDirection, data.deaccerlation.value * data.airDirectionDecay.value * Time.deltaTime);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// newDirection = Vector2.MoveTowards(currentDirection, targetDirection.Rotate(-Vector2.Angle(currentDirection, targetDirection)), 2f * Time.deltaTime);
|
// newDirection = Vector2.MoveTowards(currentDirection, targetDirection.Rotate(-Vector2.Angle(currentDirection, targetDirection)), 2f * Time.deltaTime);
|
||||||
|
|
||||||
// Commit move direction
|
// Commit move direction
|
||||||
resolvedMovement.moveDirection.Local = Vector2.SmoothDamp(
|
// resolvedMovement.moveDirection.Local = Vector2.SmoothDamp(
|
||||||
resolvedMovement.moveDirection.Local,
|
// resolvedMovement.moveDirection.Local,
|
||||||
newDirection,
|
// newDirection,
|
||||||
ref smoothing.moveSmoothing.refVel,
|
// ref smoothing.moveSmoothing.refVel,
|
||||||
smoothing.moveSmoothing.smoothing *Time.deltaTime); // TODO: Check this smoothing
|
// smoothing.moveSmoothing.smoothing *Time.deltaTime); // TODO: Check this smoothing
|
||||||
|
|
||||||
resolvedMovement.moveDirection.Local = newDirection;
|
resolvedMovement.moveDirection.Local = newDirection;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the speed, called every frame
|
// Update the speed, called every frame
|
||||||
private void UpdateCurrentSpeed(){
|
private void UpdateCurrentSpeed(){
|
||||||
//TODO: Is accel/deaccel ever used in this file????????
|
float speed;
|
||||||
|
|
||||||
resolvedMovement.moveSpeed = Mathf.Lerp(resolvedMovement.moveSpeed, data.moveSpeed.value, data.moveSpeed.smoothing * Time.deltaTime);
|
if (resolvedMovement.moveDirection.Local.magnitude < controls.rawMoveInput.magnitude) {
|
||||||
|
speed = data.moveSpeed.Value * Time.deltaTime * data.acceleration.Value;
|
||||||
|
} else {
|
||||||
|
speed = data.moveSpeed.Value * Time.deltaTime * data.deacceleration.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
resolvedMovement.moveSpeed = speed;
|
||||||
|
|
||||||
|
DebugOverlayDrawer.ChangeValue("Movement", "Resolved Speed", resolvedMovement.moveSpeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the gravity, called every frame
|
// Update the gravity, called every frame
|
||||||
private void UpdateCurrentGravity(){
|
private void UpdateCurrentGravity(){
|
||||||
// Accelerate gravity
|
// Accelerate gravity
|
||||||
if (!controller.isGrounded){
|
if (!controller.isGrounded){
|
||||||
resolvedMovement.gravity -= data.gravityAcceleration.value * Time.deltaTime;
|
resolvedMovement.gravity -= data.gravityAcceleration.Value * Time.deltaTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
// resolvedMovement.gravity = Mathf.Clamp(resolvedMovement.gravity, Mathf.NegativeInfinity, data.gravityMax.value);
|
// resolvedMovement.gravity = Mathf.Clamp(resolvedMovement.gravity, Mathf.NegativeInfinity, data.gravityMax.value);
|
||||||
@@ -285,7 +181,7 @@ namespace Reset.Units{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the final gravity value
|
// Create the final gravity value
|
||||||
float gravityMoveDirection = data.jumpPower.value + (Physics.gravity.y * resolvedMovement.gravity);
|
float gravityMoveDirection = data.jumpPower.Value + (Physics.gravity.y * resolvedMovement.gravity);
|
||||||
// resolvedMovement.gravity = data.jumpPower.value + (Physics.gravity.y * data.gravityPower.currentValue);
|
// resolvedMovement.gravity = data.jumpPower.value + (Physics.gravity.y * data.gravityPower.currentValue);
|
||||||
|
|
||||||
// Commit gravity to move direction, ignoring XZ since those are done in UpdateMovementDirection
|
// Commit gravity to move direction, ignoring XZ since those are done in UpdateMovementDirection
|
||||||
@@ -332,11 +228,12 @@ namespace Reset.Units{
|
|||||||
|
|
||||||
// Add the current input into the created rotation
|
// Add the current input into the created rotation
|
||||||
if (inputMovement.magnitude > .05){
|
if (inputMovement.magnitude > .05){
|
||||||
outputRotation = Quaternion.Lerp(outputRotation, Camera.main.transform.rotation * Quaternion.LookRotation(inputMovement), data.rotationInputBlending.value);
|
outputRotation = Quaternion.Lerp(outputRotation, Camera.main.transform.rotation * Quaternion.LookRotation(inputMovement), data.rotationInputBlending.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
// 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.value, data.rotationSpeed.smoothing * Time.deltaTime);
|
|
||||||
|
outputRotationSpeed = Mathf.Lerp(outputRotationSpeed, data.rotationSpeed.Value, data.softening.Value * Time.deltaTime);
|
||||||
|
|
||||||
// Set final rotation
|
// Set final rotation
|
||||||
transform.rotation = Quaternion.Slerp(transform.rotation, outputRotation, outputRotationSpeed * Time.deltaTime).Flatten(0, null, 0);
|
transform.rotation = Quaternion.Slerp(transform.rotation, outputRotation, outputRotationSpeed * Time.deltaTime).Flatten(0, null, 0);
|
||||||
@@ -344,7 +241,7 @@ namespace Reset.Units{
|
|||||||
|
|
||||||
// Move with default settings
|
// Move with default settings
|
||||||
public void DoMovement(){
|
public void DoMovement(){
|
||||||
DoMovement(resolvedMovement.moveDirection.Local, resolvedMovement.moveSpeed, data.gravityScale.value); // TODO: Gets multiplied a second time in DoMovement by gravity scale????
|
DoMovement(resolvedMovement.moveDirection.Local, resolvedMovement.moveSpeed, data.gravityScale.Value); // TODO: Gets multiplied a second time in DoMovement by gravity scale????
|
||||||
}
|
}
|
||||||
|
|
||||||
// Custom move from input
|
// Custom move from input
|
||||||
@@ -358,7 +255,7 @@ namespace Reset.Units{
|
|||||||
|
|
||||||
// Add their related speeds
|
// Add their related speeds
|
||||||
moveXZDir *= speed * Time.deltaTime;
|
moveXZDir *= speed * Time.deltaTime;
|
||||||
moveYDir *= data.gravityScale.value * Time.deltaTime;
|
moveYDir *= data.gravityScale.Value * Time.deltaTime;
|
||||||
addDir *= additionalSpeed * Time.deltaTime;
|
addDir *= additionalSpeed * Time.deltaTime;
|
||||||
|
|
||||||
// Construct the direction and move
|
// Construct the direction and move
|
||||||
@@ -385,21 +282,30 @@ namespace Reset.Units{
|
|||||||
|
|
||||||
// Decay the direction
|
// Decay the direction
|
||||||
if (inputMovement.magnitude < currentNoY.magnitude) {
|
if (inputMovement.magnitude < currentNoY.magnitude) {
|
||||||
additionalMoveDirection = Vector3.Slerp(additionalMoveDirection, Vector3.zero,data.acceleration.value * Time.deltaTime);
|
additionalMoveDirection = Vector3.Slerp(additionalMoveDirection, Vector3.zero,data.acceleration.Value * Time.deltaTime);
|
||||||
} else {
|
} else {
|
||||||
// float deaccelValue = data.deaccelerationCurve.Evaluate(inputMovement.magnitude);
|
// float deaccelValue = data.deaccelerationCurve.Evaluate(inputMovement.magnitude);
|
||||||
additionalMoveDirection = Vector3.Lerp(additionalMoveDirection, Vector3.zero, data.deaccerlation.value * Time.deltaTime);
|
additionalMoveDirection = Vector3.Lerp(additionalMoveDirection, Vector3.zero, data.deacceleration.Value * Time.deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decay the gravity
|
// Decay the gravity
|
||||||
additionalMoveDirection.y -= data.gravityPower.value;
|
additionalMoveDirection.y -= data.gravityPower.Value;
|
||||||
additionalMoveDirection.y = Mathf.Max(0f, additionalMoveDirection.y);
|
additionalMoveDirection.y = Mathf.Max(0f, additionalMoveDirection.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateGravityLate(){
|
private void UpdateGravityLate(){
|
||||||
// Decay jump power
|
// Decay jump power
|
||||||
data.jumpPower.value -= data.jumpPowerDecay.value * Time.deltaTime;
|
data.jumpPower.Value -= data.jumpPowerDecay.Value * Time.deltaTime;
|
||||||
data.jumpPower.value = Mathf.Max(0f, data.jumpPower.value);
|
data.jumpPower.Value = Mathf.Max(0f, data.jumpPower.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Button("Initialize Settings")]
|
||||||
|
void InitAllSettings(){
|
||||||
|
var newthing = data.GetAllSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SmoothAllSettings(){
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user