Compare commits
7 Commits
7a0499f36a
...
ff7b04341b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ff7b04341b | ||
|
|
4569cea664 | ||
|
|
bd2903a0b2 | ||
|
|
b21adf93e2 | ||
|
|
d4231d4f38 | ||
|
|
0fbef6aeee | ||
|
|
aad8b78c22 |
@@ -344,6 +344,142 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: c032a18b0b0c1da4092bfc365c6e4aad, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
data:
|
||||
mainFieldOfView:
|
||||
targetValue: 0
|
||||
currentValue: 0
|
||||
targetSmoothing: 1
|
||||
targetEasing: 2
|
||||
currentSmoothing: 1
|
||||
defaultValue: 0
|
||||
defaultSmoothing: 1
|
||||
defaultEasing: 2
|
||||
orbitPositionDamping:
|
||||
targetValue: {x: 0, y: 0, z: 0}
|
||||
currentValue: {x: 0, y: 0, z: 0}
|
||||
targetSmoothing: 1
|
||||
targetEasing: 2
|
||||
currentSmoothing: 1
|
||||
defaultValue: {x: 0, y: 0, z: 0}
|
||||
defaultSmoothing: 1
|
||||
defaultEasing: 2
|
||||
orbitTargetOffset:
|
||||
targetValue: {x: 0, y: 0, z: 0}
|
||||
currentValue: {x: 0, y: 0, z: 0}
|
||||
targetSmoothing: 1
|
||||
targetEasing: 2
|
||||
currentSmoothing: 1
|
||||
defaultValue: {x: 0, y: 0, z: 0}
|
||||
defaultSmoothing: 1
|
||||
defaultEasing: 2
|
||||
axisLookEnabledX:
|
||||
targetValue: 1
|
||||
currentValue: 1
|
||||
targetSmoothing: 1
|
||||
targetEasing: 2
|
||||
currentSmoothing: 1
|
||||
defaultValue: 1
|
||||
defaultSmoothing: 1
|
||||
defaultEasing: 2
|
||||
axisLookEnabledY:
|
||||
targetValue: 1
|
||||
currentValue: 1
|
||||
targetSmoothing: 1
|
||||
targetEasing: 2
|
||||
currentSmoothing: 1
|
||||
defaultValue: 1
|
||||
defaultSmoothing: 1
|
||||
defaultEasing: 2
|
||||
axisLookGainX:
|
||||
targetValue: 0
|
||||
currentValue: 0
|
||||
targetSmoothing: 1
|
||||
targetEasing: 2
|
||||
currentSmoothing: 1
|
||||
defaultValue: 0
|
||||
defaultSmoothing: 1
|
||||
defaultEasing: 2
|
||||
axisLookGainY:
|
||||
targetValue: 0
|
||||
currentValue: 0
|
||||
targetSmoothing: 1
|
||||
targetEasing: 2
|
||||
currentSmoothing: 1
|
||||
defaultValue: 0
|
||||
defaultSmoothing: 1
|
||||
defaultEasing: 2
|
||||
orbitFollowTopHeight:
|
||||
targetValue: 0
|
||||
currentValue: 0
|
||||
targetSmoothing: 20
|
||||
targetEasing: 2
|
||||
currentSmoothing: 1
|
||||
defaultValue: 0
|
||||
defaultSmoothing: 1
|
||||
defaultEasing: 2
|
||||
orbitFollowTopRadius:
|
||||
targetValue: 0
|
||||
currentValue: 0
|
||||
targetSmoothing: 20
|
||||
targetEasing: 2
|
||||
currentSmoothing: 1
|
||||
defaultValue: 0
|
||||
defaultSmoothing: 1
|
||||
defaultEasing: 2
|
||||
orbitFollowCenterHeight:
|
||||
targetValue: 0
|
||||
currentValue: 0
|
||||
targetSmoothing: 20
|
||||
targetEasing: 2
|
||||
currentSmoothing: 1
|
||||
defaultValue: 0
|
||||
defaultSmoothing: 1
|
||||
defaultEasing: 2
|
||||
orbitFollowCenterRadius:
|
||||
targetValue: 0
|
||||
currentValue: 0
|
||||
targetSmoothing: 20
|
||||
targetEasing: 2
|
||||
currentSmoothing: 1
|
||||
defaultValue: 0
|
||||
defaultSmoothing: 1
|
||||
defaultEasing: 2
|
||||
orbitFollowBottomHeight:
|
||||
targetValue: 0
|
||||
currentValue: 0
|
||||
targetSmoothing: 20
|
||||
targetEasing: 2
|
||||
currentSmoothing: 1
|
||||
defaultValue: 0
|
||||
defaultSmoothing: 1
|
||||
defaultEasing: 2
|
||||
orbitFollowBottomRadius:
|
||||
targetValue: 0
|
||||
currentValue: 0
|
||||
targetSmoothing: 20
|
||||
targetEasing: 2
|
||||
currentSmoothing: 1
|
||||
defaultValue: 0
|
||||
defaultSmoothing: 1
|
||||
defaultEasing: 2
|
||||
rotationComposerScreenPos:
|
||||
targetValue: {x: 0, y: 0}
|
||||
currentValue: {x: 0, y: 0}
|
||||
targetSmoothing: 1
|
||||
targetEasing: 2
|
||||
currentSmoothing: 1
|
||||
defaultValue: {x: 0, y: 0}
|
||||
defaultSmoothing: 1
|
||||
defaultEasing: 2
|
||||
cameraOffsetOffset:
|
||||
targetValue: {x: 0, y: 0, z: 0}
|
||||
currentValue: {x: 0, y: 0, z: 0}
|
||||
targetSmoothing: 1
|
||||
targetEasing: 2
|
||||
currentSmoothing: 1
|
||||
defaultValue: {x: 0, y: 0, z: 0}
|
||||
defaultSmoothing: 1
|
||||
defaultEasing: 2
|
||||
--- !u!114 &4383369033389970653
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -208,50 +208,133 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: b3b4e13d59527d1429a62dde97c6a001, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
outputMoveDirection: {x: 0, y: 0, z: 0}
|
||||
additionalMoveDirection: {x: 0, y: 0, z: 0}
|
||||
gravitySmooth: 0
|
||||
data:
|
||||
accelerationSmoothing: 5
|
||||
deaccelerationSmoothing: 5
|
||||
airDirectionDecay: 0
|
||||
moveSpeed: 15
|
||||
moveSpeedSoothing: 10
|
||||
jumpPower: 0
|
||||
jumpPowerDecay: 3
|
||||
gravityPower: 0
|
||||
gravityMax: 8
|
||||
gravityAcceleration: 1
|
||||
gravityScale: 1
|
||||
settingsChangeSmoothing: 6
|
||||
rotateFacing:
|
||||
rid: -2
|
||||
rotationSpeed: 5
|
||||
rotationSmoothing: 1
|
||||
rotationInputBlending: 0.3
|
||||
defaultData:
|
||||
accelerationSmoothing: 5
|
||||
deaccelerationSmoothing: 5
|
||||
airDirectionDecay: 0
|
||||
moveSpeed: 15
|
||||
moveSpeedSoothing: 10
|
||||
jumpPower: 0
|
||||
jumpPowerDecay: 3
|
||||
gravityPower: 0
|
||||
gravityMax: 8
|
||||
gravityAcceleration: 1
|
||||
gravityScale: 1
|
||||
settingsChangeSmoothing: 6
|
||||
rotateFacing:
|
||||
rid: -2
|
||||
rotationSpeed: 5
|
||||
rotationSmoothing: 1
|
||||
rotationInputBlending: 0.3
|
||||
references:
|
||||
version: 2
|
||||
RefIds:
|
||||
- rid: -2
|
||||
type: {class: , ns: , asm: }
|
||||
directionChangingSoftness:
|
||||
targetValue: 1
|
||||
currentValue: 1
|
||||
targetSmoothing: 1
|
||||
targetEasing: 2
|
||||
currentSmoothing: 1
|
||||
defaultValue: 1
|
||||
defaultSmoothing: 1
|
||||
defaultEasing: 2
|
||||
directionSpinningHardness:
|
||||
targetValue: 30
|
||||
currentValue: 30
|
||||
targetSmoothing: 1
|
||||
targetEasing: 2
|
||||
currentSmoothing: 1
|
||||
defaultValue: 3
|
||||
defaultSmoothing: 1
|
||||
defaultEasing: 2
|
||||
directionSpinningSpeed:
|
||||
targetValue: 5
|
||||
currentValue: 5
|
||||
targetSmoothing: 1
|
||||
targetEasing: 2
|
||||
currentSmoothing: 1
|
||||
defaultValue: 3
|
||||
defaultSmoothing: 1
|
||||
defaultEasing: 2
|
||||
airDirectionDecay:
|
||||
targetValue: 1
|
||||
currentValue: 1
|
||||
targetSmoothing: 1
|
||||
targetEasing: 2
|
||||
currentSmoothing: 1
|
||||
defaultValue: 1
|
||||
defaultSmoothing: 1
|
||||
defaultEasing: 2
|
||||
acceleration:
|
||||
targetValue: 28
|
||||
currentValue: 28
|
||||
targetSmoothing: 1
|
||||
targetEasing: 2
|
||||
currentSmoothing: 1
|
||||
defaultValue: 5
|
||||
defaultSmoothing: 1
|
||||
defaultEasing: 2
|
||||
deacceleration:
|
||||
targetValue: 20
|
||||
currentValue: 20
|
||||
targetSmoothing: 1
|
||||
targetEasing: 2
|
||||
currentSmoothing: 1
|
||||
defaultValue: 5
|
||||
defaultSmoothing: 1
|
||||
defaultEasing: 2
|
||||
moveSpeed:
|
||||
targetValue: 15
|
||||
currentValue: 15
|
||||
targetSmoothing: 10
|
||||
targetEasing: 2
|
||||
currentSmoothing: 10
|
||||
defaultValue: 15
|
||||
defaultSmoothing: 10
|
||||
defaultEasing: 2
|
||||
gravityPower:
|
||||
targetValue: 1
|
||||
currentValue: 1
|
||||
targetSmoothing: 1
|
||||
targetEasing: 2
|
||||
currentSmoothing: 1
|
||||
defaultValue: 1
|
||||
defaultSmoothing: 1
|
||||
defaultEasing: 2
|
||||
gravityMax:
|
||||
targetValue: 4
|
||||
currentValue: 4
|
||||
targetSmoothing: 1
|
||||
targetEasing: 2
|
||||
currentSmoothing: 1
|
||||
defaultValue: 8
|
||||
defaultSmoothing: 1
|
||||
defaultEasing: 2
|
||||
gravityAcceleration:
|
||||
targetValue: 15
|
||||
currentValue: 15
|
||||
targetSmoothing: 1
|
||||
targetEasing: 2
|
||||
currentSmoothing: 1
|
||||
defaultValue: 1
|
||||
defaultSmoothing: 1
|
||||
defaultEasing: 2
|
||||
gravityScale:
|
||||
targetValue: 1
|
||||
currentValue: 1
|
||||
targetSmoothing: 1
|
||||
targetEasing: 2
|
||||
currentSmoothing: 1
|
||||
defaultValue: 1
|
||||
defaultSmoothing: 1
|
||||
defaultEasing: 2
|
||||
facingDirection:
|
||||
targetValue: 4
|
||||
currentValue: 4
|
||||
targetSmoothing: 1
|
||||
targetEasing: 2
|
||||
currentSmoothing: 1
|
||||
defaultValue: 4
|
||||
defaultSmoothing: 1
|
||||
defaultEasing: 2
|
||||
rotationSpeed:
|
||||
targetValue: 5
|
||||
currentValue: 5
|
||||
targetSmoothing: 1
|
||||
targetEasing: 2
|
||||
currentSmoothing: 1
|
||||
defaultValue: 5
|
||||
defaultSmoothing: 1
|
||||
defaultEasing: 2
|
||||
rotationInputBlending:
|
||||
targetValue: 0.3
|
||||
currentValue: 0.3
|
||||
targetSmoothing: 1
|
||||
targetEasing: 2
|
||||
currentSmoothing: 1
|
||||
defaultValue: 0.3
|
||||
defaultSmoothing: 1
|
||||
defaultEasing: 2
|
||||
--- !u!114 &679199079481597207
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -438,7 +521,7 @@ MonoBehaviour:
|
||||
offset: {x: 0, y: 0.8, z: 0}
|
||||
ignoreLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 64
|
||||
m_Bits: 0
|
||||
width: 0
|
||||
size: {x: 2.1, y: 2.9, z: 0.4}
|
||||
rotation: {x: 9, y: 0, z: 0}
|
||||
@@ -562,6 +645,7 @@ MonoBehaviour:
|
||||
UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"},"currentSpeed":{"_name":"currentSpeed","_id":"f585caab-68c5-4ead-85c4-cbc16c18655e","$type":"NodeCanvas.Framework.Variable`1[[System.Single,
|
||||
mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"},"movementData":{"_propertyPath":"Reset.Units.UnitMovementHandler.data","_name":"movementData","_id":"357123c2-2d10-4425-a3c9-7341e810fc88","$type":"NodeCanvas.Framework.Variable`1[[Reset.Units.UnitMovementData,
|
||||
Core, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"},"outputMoveDirection":{"_propertyPath":"Reset.Units.UnitMovementHandler.outputMoveDirection","_name":"outputMoveDirection","_id":"3b9833f5-870a-4182-9824-e31a9896eec2","$type":"NodeCanvas.Framework.Variable`1[[UnityEngine.Vector3,
|
||||
UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"},"myVector3":{"_name":"myVector3","_id":"9367e2ee-ac93-43f7-9cd7-6a7cf167e07a","$type":"NodeCanvas.Framework.Variable`1[[UnityEngine.Vector3,
|
||||
UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"}}}'
|
||||
_objectReferences: []
|
||||
_serializedVariables:
|
||||
@@ -586,6 +670,9 @@ MonoBehaviour:
|
||||
- _json: '{"_propertyPath":"Reset.Units.UnitMovementHandler.outputMoveDirection","_name":"outputMoveDirection","_id":"3b9833f5-870a-4182-9824-e31a9896eec2","$type":"NodeCanvas.Framework.Variable`1[[UnityEngine.Vector3,
|
||||
UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"}'
|
||||
_references: []
|
||||
- _json: '{"_name":"myVector3","_id":"9367e2ee-ac93-43f7-9cd7-6a7cf167e07a","$type":"NodeCanvas.Framework.Variable`1[[UnityEngine.Vector3,
|
||||
UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"}'
|
||||
_references: []
|
||||
--- !u!114 &43868462096200776
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -2971,19 +2971,19 @@ PrefabInstance:
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1478733240008970968, guid: 6ae1b39ffbe1f0f468d521bb08a8b547, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 0.9996973
|
||||
value: 0.99973595
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1478733240008970968, guid: 6ae1b39ffbe1f0f468d521bb08a8b547, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: -0.024602825
|
||||
value: -0.022979952
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1478733240008970968, guid: 6ae1b39ffbe1f0f468d521bb08a8b547, type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0.000000011836157
|
||||
value: 3.1949018e-10
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1478733240008970968, guid: 6ae1b39ffbe1f0f468d521bb08a8b547, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 2.9129085e-10
|
||||
value: 7.3437315e-12
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1478733240008970968, guid: 6ae1b39ffbe1f0f468d521bb08a8b547, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
@@ -3001,6 +3001,10 @@ PrefabInstance:
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 5
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3229831872226355039, guid: 6ae1b39ffbe1f0f468d521bb08a8b547, type: 3}
|
||||
propertyPath: Composition.ScreenPosition.y
|
||||
value: 0.14794445
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3716971538123186913, guid: 6ae1b39ffbe1f0f468d521bb08a8b547, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: CameraGroup
|
||||
@@ -3019,24 +3023,48 @@ PrefabInstance:
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5136833180492354989, guid: 6ae1b39ffbe1f0f468d521bb08a8b547, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 0.9996973
|
||||
value: 0.99973595
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5136833180492354989, guid: 6ae1b39ffbe1f0f468d521bb08a8b547, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: -0.024602825
|
||||
value: -0.022979954
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5136833180492354989, guid: 6ae1b39ffbe1f0f468d521bb08a8b547, type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0.000000011836157
|
||||
value: 3.1949024e-10
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5136833180492354989, guid: 6ae1b39ffbe1f0f468d521bb08a8b547, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 2.9129105e-10
|
||||
value: 7.34381e-12
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5136833180492354989, guid: 6ae1b39ffbe1f0f468d521bb08a8b547, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: -89
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7070283194321853303, guid: 6ae1b39ffbe1f0f468d521bb08a8b547, type: 3}
|
||||
propertyPath: data.orbitFollowTopHeight.targetSmoothing
|
||||
value: 20
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7070283194321853303, guid: 6ae1b39ffbe1f0f468d521bb08a8b547, type: 3}
|
||||
propertyPath: data.orbitFollowTopRadius.targetSmoothing
|
||||
value: 20
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7070283194321853303, guid: 6ae1b39ffbe1f0f468d521bb08a8b547, type: 3}
|
||||
propertyPath: data.orbitFollowBottomHeight.targetSmoothing
|
||||
value: 20
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7070283194321853303, guid: 6ae1b39ffbe1f0f468d521bb08a8b547, type: 3}
|
||||
propertyPath: data.orbitFollowBottomRadius.targetSmoothing
|
||||
value: 20
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7070283194321853303, guid: 6ae1b39ffbe1f0f468d521bb08a8b547, type: 3}
|
||||
propertyPath: data.orbitFollowCenterHeight.targetSmoothing
|
||||
value: 20
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7070283194321853303, guid: 6ae1b39ffbe1f0f468d521bb08a8b547, type: 3}
|
||||
propertyPath: data.orbitFollowCenterRadius.targetSmoothing
|
||||
value: 20
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
|
||||
@@ -9,16 +9,17 @@ namespace NodeCanvas.Tasks.Actions {
|
||||
[Category("Reset")]
|
||||
[Description("Change Cinemachine camera settings for the player")]
|
||||
public class ChangeCameraSettings : ActionTask{
|
||||
[ParadoxNotion.Design.Header("Main Settings")]
|
||||
[ParadoxNotion.Design.Header("Main Settings"), Space(8)]
|
||||
public FloatValueGroup fieldOfView = new (newLabel: "FOV");
|
||||
|
||||
[ParadoxNotion.Design.Header("Orbit Follow Ring Settings"), Space (5)]
|
||||
public Vector3ValueGroup orbitTargetOffset = new(newLabel: "Target Offset");
|
||||
[Space(5)]public Vector3ValueGroup orbitPositionDamping = new(newLabel: "Position Damping");
|
||||
|
||||
public OrbitalFollowValueGroup orbitFollowTop = new (newLabel: "Top");
|
||||
public OrbitalFollowValueGroup orbitFollowCenter = new (newLabel: "Center");
|
||||
public OrbitalFollowValueGroup orbitFollowBottom = new (newLabel: "Bottom");
|
||||
[ParadoxNotion.Design.Header("Orbit Follow Ring Settings"), Space (5)]
|
||||
public OrbitalFollowValueGroup orbitFollowTop = new (newLabel: "Top Ring");
|
||||
public OrbitalFollowValueGroup orbitFollowCenter = new (newLabel: "Top Ring");
|
||||
[Space(8)]
|
||||
public OrbitalFollowValueGroup orbitFollowBottom = new (newLabel: "Top Ring");
|
||||
|
||||
public BoolValueGroup enableXAxis = new (newLabel: "Input Axis X Enabled");
|
||||
public BoolValueGroup enableYAxis = new (newLabel: "Input Axis Y Enabled");
|
||||
@@ -26,15 +27,18 @@ namespace NodeCanvas.Tasks.Actions {
|
||||
public FloatValueGroup axisLookXGain = new (newLabel: "Look Orbit X Gain");
|
||||
public FloatValueGroup axisLookYGain = new (newLabel: "Look Orbit Y Gain");
|
||||
|
||||
[ParadoxNotion.Design.Header("Rotation Composer Settings")]
|
||||
[ParadoxNotion.Design.Header("Rotation Composer Settings"), Space(8)]
|
||||
public Vector2ValueGroup screenPosition = new (newLabel: "Screen Position");
|
||||
|
||||
[ParadoxNotion.Design.Header("Camera Offset Settings")]
|
||||
[ParadoxNotion.Design.Header("Camera Offset Settings"), Space(8)]
|
||||
public Vector3ValueGroup cameraOffset = new (newLabel: "Offset");
|
||||
|
||||
private CameraSettingsProcessor processor;
|
||||
|
||||
//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(){
|
||||
processor = CameraSettingsProcessor.Instance;
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -42,119 +46,28 @@ namespace NodeCanvas.Tasks.Actions {
|
||||
//Call EndAction() to mark the action as finished, either in success or failure.
|
||||
//EndAction can be called from anywhere.
|
||||
protected override void OnExecute(){
|
||||
UpdateOrbitFollowValue(orbitFollowTop, ref CameraSettingsProcessor.values.orbitFollowTopHeight, ref CameraSettingsProcessor.values.orbitFollowTopRadius);
|
||||
UpdateOrbitFollowValue(orbitFollowCenter, ref CameraSettingsProcessor.values.orbitFollowCenterHeight, ref CameraSettingsProcessor.values.orbitFollowCenterRadius);
|
||||
UpdateOrbitFollowValue(orbitFollowBottom, ref CameraSettingsProcessor.values.orbitFollowBottomHeight, ref CameraSettingsProcessor.values.orbitFollowBottomRadius);
|
||||
OrbitalFollowValueGroup.UpdateValue(orbitFollowTop, processor.data.orbitFollowTopHeight, processor.data.orbitFollowTopRadius);
|
||||
OrbitalFollowValueGroup.UpdateValue(orbitFollowCenter, processor.data.orbitFollowCenterHeight, processor.data.orbitFollowCenterRadius);
|
||||
OrbitalFollowValueGroup.UpdateValue(orbitFollowBottom, processor.data.orbitFollowBottomHeight, processor.data.orbitFollowBottomRadius);
|
||||
|
||||
UpdateVector3Value(cameraOffset, ref CameraSettingsProcessor.values.cameraOffsetOffset);
|
||||
Vector3ValueGroup.UpdateValue(cameraOffset, processor.data.cameraOffsetOffset);
|
||||
|
||||
UpdateVector3Value(orbitPositionDamping, ref CameraSettingsProcessor.values.orbitPositionDamping);
|
||||
UpdateVector3Value(orbitTargetOffset, ref CameraSettingsProcessor.values.orbitTargetOffset);
|
||||
Vector3ValueGroup.UpdateValue(orbitPositionDamping, processor.data.orbitPositionDamping);
|
||||
Vector3ValueGroup.UpdateValue(orbitTargetOffset, processor.data.orbitTargetOffset);
|
||||
|
||||
UpdateVector2Value(screenPosition, ref CameraSettingsProcessor.values.rotationComposerScreenPos);
|
||||
UpdateFloatValue(fieldOfView, ref CameraSettingsProcessor.values.mainFieldOfView);
|
||||
Vector2ValueGroup.UpdateValue(screenPosition, processor.data.rotationComposerScreenPos);
|
||||
|
||||
UpdateFloatValue(axisLookXGain, ref CameraSettingsProcessor.values.axisLookGainX);
|
||||
UpdateFloatValue(axisLookYGain, ref CameraSettingsProcessor.values.axisLookGainY);
|
||||
FloatValueGroup.UpdateValue(fieldOfView, processor.data.mainFieldOfView);
|
||||
|
||||
UpdateBoolValue(enableXAxis, ref CameraSettingsProcessor.values.axisLookEnabledX);
|
||||
UpdateBoolValue(enableYAxis, ref CameraSettingsProcessor.values.axisLookEnabledY);
|
||||
FloatValueGroup.UpdateValue(axisLookXGain, processor.data.axisLookGainX);
|
||||
FloatValueGroup.UpdateValue(axisLookYGain, processor.data.axisLookGainY);
|
||||
|
||||
BoolValueGroup.UpdateValue(enableXAxis, processor.data.axisLookEnabledX);
|
||||
BoolValueGroup.UpdateValue(enableYAxis, processor.data.axisLookEnabledY);
|
||||
|
||||
EndAction(true);
|
||||
}
|
||||
|
||||
public void UpdateVector3Value(Vector3ValueGroup valueGroup, ref CameraSettingSingleValue<Vector3> targetProperty){
|
||||
switch (valueGroup.changeX) {
|
||||
case ValueChangeAction.NewValue:
|
||||
targetProperty.targetValue.x = valueGroup.newValue.x;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
targetProperty.targetValue.x = targetProperty.originalValue.x;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (valueGroup.changeY) {
|
||||
case ValueChangeAction.NewValue:
|
||||
targetProperty.targetValue.y = valueGroup.newValue.y;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
targetProperty.targetValue.y = targetProperty.originalValue.y;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (valueGroup.changeZ) {
|
||||
case ValueChangeAction.NewValue:
|
||||
targetProperty.targetValue.z = valueGroup.newValue.z;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
targetProperty.targetValue.z = targetProperty.originalValue.z;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateVector2Value(Vector2ValueGroup valueGroup, ref CameraSettingSingleValue<Vector2> targetProperty){
|
||||
switch (valueGroup.changeX) {
|
||||
case ValueChangeAction.NewValue:
|
||||
targetProperty.targetValue.x = valueGroup.newValue.x;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
targetProperty.targetValue.x = targetProperty.originalValue.x;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (valueGroup.changeY) {
|
||||
case ValueChangeAction.NewValue:
|
||||
targetProperty.targetValue.y = valueGroup.newValue.y;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
targetProperty.targetValue.y = targetProperty.originalValue.y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateOrbitFollowValue(OrbitalFollowValueGroup valueGroup, ref CameraSettingSingleValue<float> targetHeight, ref CameraSettingSingleValue<float> targetRadius){
|
||||
switch (valueGroup.changeHeight) {
|
||||
case ValueChangeAction.NewValue:
|
||||
targetHeight.targetValue = valueGroup.height;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
targetHeight.targetValue = targetHeight.originalValue;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (valueGroup.changeRadius) {
|
||||
case ValueChangeAction.NewValue:
|
||||
targetRadius.targetValue = valueGroup.radius;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
targetRadius.targetValue = targetRadius.originalValue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateBoolValue(BoolValueGroup valueGroup, ref CameraSettingSingleValue<bool> targetProperty){
|
||||
switch (valueGroup.changeValue) {
|
||||
case ValueChangeAction.NewValue:
|
||||
targetProperty.targetValue = valueGroup.value;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
targetProperty.targetValue = targetProperty.originalValue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateFloatValue(FloatValueGroup valueGroup, ref CameraSettingSingleValue<float> targetProperty){
|
||||
switch (valueGroup.changeValue) {
|
||||
case ValueChangeAction.NewValue:
|
||||
targetProperty.targetValue = valueGroup.value.value;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
targetProperty.targetValue = targetProperty.originalValue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Called once per frame while the action is active.
|
||||
protected override void OnUpdate() {
|
||||
|
||||
|
||||
@@ -1,235 +0,0 @@
|
||||
using System;
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using Reset.Units;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Reset.Core {
|
||||
[Category("Reset")]
|
||||
[Description("Commits movement unit changes to the handler.")]
|
||||
public class ChangeMovementSettings : ActionTask<UnitMovementHandler> {
|
||||
// Move Speed
|
||||
[ParadoxNotion.Design.Header("Speed")]
|
||||
public FloatValueGroup moveSpeed = new (newLabel: "Move Speed");
|
||||
public FloatValueGroup moveSpeedSoothing = new (newLabel: "Move Speed Smoothing");
|
||||
|
||||
[ParadoxNotion.Design.Header("Direction")]
|
||||
public FloatValueGroup airDirectionDecay = new FloatValueGroup("Air Direction Decay");
|
||||
public FloatValueGroup accelerationSmoothing = new (newLabel: "Acceleration Smoothing");
|
||||
public FloatValueGroup deaccelerationSmoothing = new (newLabel: "Deacceleration Smoothing");
|
||||
// public CurveValueGroup deaccelerationCurve = new (newLabel: "Deacceleration Curve"); // Currently unused, may return
|
||||
|
||||
// Direction
|
||||
[Space(5)]
|
||||
public Vector3ValueGroup feedNewDirection = new Vector3ValueGroup("Feed New Direction");
|
||||
public float newDirectionStrength;
|
||||
[Space(5)]
|
||||
public Vector2 addDirectionFromInput;
|
||||
public float addInputStrength;
|
||||
[SliderField(0,1)]
|
||||
public float addInputPriorty;
|
||||
|
||||
// Jumping
|
||||
[ParadoxNotion.Design.Header("Jumping")]
|
||||
public FloatValueGroup jumpPower = new (newLabel: "Jump Power");
|
||||
public FloatValueGroup jumpPowerDecay = new (newLabel: "Jump Decay Speed");
|
||||
|
||||
// Gravity
|
||||
[ParadoxNotion.Design.Header("Gravity")]
|
||||
public FloatValueGroup gravityPower = new (newLabel: "Gravity Power");
|
||||
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")]
|
||||
public EnumValueGroup rotateFacing = new EnumValueGroup("Facing Direction", PlayerFacingDirection.TowardsTarget);
|
||||
public FloatValueGroup rotationSpeed = new (newLabel: "Rotation Speed");
|
||||
public FloatValueGroup rotationSmoothing = new (newLabel: "Rotation Smoothing");
|
||||
public FloatValueGroup rotationInputBlending = new("Rotation Input Blending");
|
||||
[Space(5)]
|
||||
public BBParameter<Vector3> feedNewRotation;
|
||||
public BBParameter<Vector3> feedRelativeTo;
|
||||
public Space rotationRelativeSpace;
|
||||
|
||||
private Vector3 feedDir;
|
||||
|
||||
protected override string OnInit() {
|
||||
return null;
|
||||
}
|
||||
|
||||
//This is called once each time the task is enabled.
|
||||
//Call EndAction() to mark the action as finished, either in success or failure.
|
||||
//EndAction can be called from anywhere.
|
||||
protected override void OnExecute() {
|
||||
// Direction
|
||||
UpdateFloatValue(airDirectionDecay, ref agent.data.airDirectionDecay, ref agent.data.airDirectionDecay);
|
||||
UpdateFloatValue(accelerationSmoothing, ref agent.data.accelerationSmoothing, ref agent.defaultData.accelerationSmoothing);
|
||||
UpdateFloatValue(deaccelerationSmoothing, ref agent.data.deaccelerationSmoothing, ref agent.defaultData.deaccelerationSmoothing);
|
||||
// UpdateCurveProperty(deaccelerationCurve, ref agent.data.deaccelerationCurve, ref agent.defaultData.deaccelerationCurve); // Currently unused, may return
|
||||
|
||||
// Direction from value
|
||||
// Check that feedDir is not changed
|
||||
UpdateVector3Value(feedNewDirection, ref feedDir, ref feedDir);
|
||||
|
||||
// If there's a direciton add it to the player for a frame
|
||||
if (feedDir != Vector3.zero) {
|
||||
agent.AddToCurrentDirection(agent.transform.rotation * feedDir.normalized, newDirectionStrength);
|
||||
// Reset the fed direction after it's added so future runs don't have
|
||||
feedDir = Vector3.zero;
|
||||
}
|
||||
|
||||
// Direction from controller input
|
||||
if (addDirectionFromInput != Vector2.zero){
|
||||
agent.OverwriteDirectionFromInput(new Vector3(addDirectionFromInput.x, addDirectionFromInput.y), addInputPriorty, addInputStrength);
|
||||
}
|
||||
|
||||
// Move Speed
|
||||
UpdateFloatValue(moveSpeed, ref agent.data.moveSpeed, ref agent.defaultData.moveSpeed);
|
||||
UpdateFloatValue(moveSpeedSoothing, ref agent.data.moveSpeedSoothing, ref agent.defaultData.moveSpeedSoothing);
|
||||
|
||||
// Jump
|
||||
UpdateFloatValue(jumpPower, ref agent.data.jumpPower, ref agent.defaultData.jumpPower);
|
||||
UpdateFloatValue(jumpPowerDecay, ref agent.data.jumpPowerDecay, ref agent.defaultData.jumpPowerDecay);
|
||||
|
||||
// Gravity
|
||||
UpdateFloatValue(gravityPower, ref agent.data.gravityPower, ref agent.defaultData.gravityPower);
|
||||
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.defaultData.settingsChangeSmoothing);
|
||||
|
||||
// Rotation
|
||||
UpdateEnumValue(rotateFacing, ref agent.data.rotateFacing, ref agent.defaultData.rotateFacing);
|
||||
UpdateFloatValue(rotationSpeed, ref agent.data.rotationSpeed, ref agent.defaultData.rotationSpeed);
|
||||
UpdateFloatValue(rotationSmoothing, ref agent.data.rotationSmoothing, ref agent.defaultData.rotationSmoothing);
|
||||
UpdateFloatValue(rotationInputBlending, ref agent.data.rotationInputBlending, ref agent.defaultData.rotationInputBlending);
|
||||
|
||||
// Rotation from value
|
||||
if (feedNewRotation.value != Vector3.zero) {
|
||||
if (rotationRelativeSpace == Space.World) {
|
||||
Debug.Log(Quaternion.LookRotation(feedRelativeTo.value));
|
||||
agent.SetSpecifiedRotation(Quaternion.Euler(feedNewRotation.value) * Quaternion.LookRotation(feedRelativeTo.value));
|
||||
} else {
|
||||
agent.SetSpecifiedRotation(agent.transform.rotation * Quaternion.Euler(feedNewRotation.value) * Quaternion.LookRotation(feedRelativeTo.value));
|
||||
}
|
||||
}
|
||||
|
||||
EndAction(true);
|
||||
}
|
||||
|
||||
//Called once per frame while the action is active.
|
||||
protected override void OnUpdate() {
|
||||
|
||||
}
|
||||
|
||||
//Called when the task is disabled.
|
||||
protected override void OnStop() {
|
||||
|
||||
}
|
||||
|
||||
//Called when the task is paused.
|
||||
protected override void OnPause() {
|
||||
|
||||
}
|
||||
|
||||
public void UpdateCurveProperty(CurveValueGroup valueGroup, ref AnimationCurve targetProperty, ref AnimationCurve defaultProperty){
|
||||
switch (valueGroup.changeValue) {
|
||||
case ValueChangeAction.NoChange:
|
||||
break;
|
||||
case ValueChangeAction.NewValue:
|
||||
targetProperty = valueGroup.newValue;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
targetProperty = defaultProperty;
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateVector3Value(Vector3ValueGroup valueGroup, ref Vector3 targetProperty, ref Vector3 defaultProperty){
|
||||
switch (valueGroup.changeX) {
|
||||
case ValueChangeAction.NewValue:
|
||||
targetProperty.x = valueGroup.newValue.x;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
targetProperty.x = defaultProperty.x;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (valueGroup.changeY) {
|
||||
case ValueChangeAction.NewValue:
|
||||
targetProperty.y = valueGroup.newValue.y;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
targetProperty.y = defaultProperty.y;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (valueGroup.changeZ) {
|
||||
case ValueChangeAction.NewValue:
|
||||
targetProperty.z = valueGroup.newValue.z;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
targetProperty.z = defaultProperty.z;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateVector2Value(Vector2ValueGroup valueGroup, ref Vector2 targetProperty, ref Vector2 defaultProperty){
|
||||
switch (valueGroup.changeX) {
|
||||
case ValueChangeAction.NewValue:
|
||||
targetProperty.x = valueGroup.newValue.x;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
targetProperty.x = defaultProperty.x;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (valueGroup.changeY) {
|
||||
case ValueChangeAction.NewValue:
|
||||
targetProperty.y = valueGroup.newValue.y;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
targetProperty.y = defaultProperty.y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void UpdateBoolValue(BoolValueGroup valueGroup, ref bool targetProperty, ref bool defaultProperty){
|
||||
switch (valueGroup.changeValue) {
|
||||
case ValueChangeAction.NewValue:
|
||||
targetProperty = valueGroup.value;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
targetProperty = defaultProperty;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateEnumValue(EnumValueGroup valueGroup, ref Enum targetProperty, ref Enum defaultProperty){
|
||||
switch (valueGroup.changeValue) {
|
||||
case ValueChangeAction.NewValue:
|
||||
targetProperty = valueGroup.newValue;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
targetProperty = defaultProperty;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateFloatValue(FloatValueGroup valueGroup, ref float targetProperty, ref float defaultProperty){
|
||||
switch (valueGroup.changeValue) {
|
||||
case ValueChangeAction.NewValue:
|
||||
targetProperty = valueGroup.value.value;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
targetProperty = defaultProperty;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5132a76af4f722e49bc7fbbc75edcaf1
|
||||
@@ -69,7 +69,7 @@ namespace NodeCanvas.Tasks.Actions {
|
||||
directionOnStart = agent.transform.position.DirectionTo(grapplePoint.value);
|
||||
|
||||
// Get the current move direction
|
||||
velocityOnStart = agent.outputMoveDirection;
|
||||
// velocityOnStart = agent.outputMoveDirection; // NOTE: Deprecated by new movement values
|
||||
|
||||
// For setting finalDirection's initial value, first compose the swing variables one-time
|
||||
Vector3 velocityWhenMoving = CalculateSwingDirections(Vector3.Distance(agent.transform.position, grapplePoint.value), directionOnStart);
|
||||
@@ -86,7 +86,7 @@ namespace NodeCanvas.Tasks.Actions {
|
||||
|
||||
//Called once per frame while the action is active.
|
||||
protected override void OnUpdate(){
|
||||
agent.outputMoveDirection = Vector3.MoveTowards(agent.outputMoveDirection, Vector3.zero, .5f);
|
||||
// agent.outputMoveDirection = Vector3.MoveTowards(agent.outputMoveDirection, Vector3.zero, .5f); // NOTE: Deprecated by new movement values
|
||||
|
||||
// Basic variables, direction to point and current distnace
|
||||
Vector3 directionToPoint = agent.transform.position.DirectionTo(grapplePoint.value);
|
||||
@@ -178,7 +178,7 @@ namespace NodeCanvas.Tasks.Actions {
|
||||
gizmoFinalDirection = finalDirection;
|
||||
|
||||
// Finalize the movement to the controller
|
||||
agent.SetNewDirection(Vector3.Lerp(agent.additionalMoveDirection, finalDirection.Flatten(null, 0), 1f * Time.deltaTime));
|
||||
// agent.SetNewDirection(Vector3.Lerp(agent.additionalMoveDirection, finalDirection.Flatten(null, 0), 1f * Time.deltaTime)); // NOTE: Deprecated by new movement values
|
||||
agent.SetNewGravity(finalDirection.y);
|
||||
agent.SmoothToSpeed(speed, 25f * Time.deltaTime);
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7879b20d5bcdf974c823d1919491e026
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,48 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using Reset.Core;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Reset.Units {
|
||||
|
||||
[Category("Reset/Movement")]
|
||||
public class ChangeDirectionSettings : ActionTask<UnitMovementHandler> {
|
||||
// Direction
|
||||
[Space(5)]
|
||||
public FloatValueGroup directionChangingSoftness = new FloatValueGroup("Direction Changing Softness");
|
||||
public FloatValueGroup directionSpinningHardness = new FloatValueGroup("Direction Spinning Hardness");
|
||||
public FloatValueGroup directionSpinningSpeed = new FloatValueGroup("Direction Spinning Speed");
|
||||
|
||||
//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() {
|
||||
return null;
|
||||
}
|
||||
|
||||
//This is called once each time the task is enabled.
|
||||
//Call EndAction() to mark the action as finished, either in success or failure.
|
||||
//EndAction can be called from anywhere.
|
||||
protected override void OnExecute() {
|
||||
FloatValueGroup.UpdateValue(directionChangingSoftness, agent.data.directionChangingSoftness);
|
||||
FloatValueGroup.UpdateValue(directionSpinningHardness, agent.data.directionSpinningHardness);
|
||||
FloatValueGroup.UpdateValue(directionSpinningSpeed, agent.data.directionSpinningSpeed);
|
||||
|
||||
EndAction(true);
|
||||
}
|
||||
|
||||
//Called once per frame while the action is active.
|
||||
protected override void OnUpdate() {
|
||||
|
||||
}
|
||||
|
||||
//Called when the task is disabled.
|
||||
protected override void OnStop() {
|
||||
|
||||
}
|
||||
|
||||
//Called when the task is paused.
|
||||
protected override void OnPause() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e97f34b81238a9548b0bf4f5b68c8f17
|
||||
@@ -0,0 +1,48 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using Reset.Core;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Reset.Units {
|
||||
|
||||
[Category("Reset/Movement")]
|
||||
public class ChangeGravitySettings : ActionTask<UnitMovementHandler>{
|
||||
[SliderField(0f, 1f), SerializeField] public FloatValueGroup airDirectionDecay = new FloatValueGroup("Air Direction Decay");
|
||||
|
||||
[SerializeField] public FloatValueGroup gravityMax = new FloatValueGroup("Gravity Max");
|
||||
[SerializeField] public FloatValueGroup gravityAcceleration = new FloatValueGroup("Gravity Acceleration");
|
||||
[SerializeField] public FloatValueGroup gravityScale = new FloatValueGroup("Gravity Scale");
|
||||
|
||||
//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() {
|
||||
return null;
|
||||
}
|
||||
|
||||
//This is called once each time the task is enabled.
|
||||
//Call EndAction() to mark the action as finished, either in success or failure.
|
||||
//EndAction can be called from anywhere.
|
||||
protected override void OnExecute() {
|
||||
FloatValueGroup.UpdateValue(airDirectionDecay, agent.data.airDirectionDecay);
|
||||
|
||||
FloatValueGroup.UpdateValue(gravityMax, agent.data.gravityMax);
|
||||
FloatValueGroup.UpdateValue(gravityAcceleration, agent.data.gravityAcceleration);
|
||||
FloatValueGroup.UpdateValue(gravityScale, agent.data.gravityScale);
|
||||
}
|
||||
|
||||
//Called once per frame while the action is active.
|
||||
protected override void OnUpdate() {
|
||||
|
||||
}
|
||||
|
||||
//Called when the task is disabled.
|
||||
protected override void OnStop() {
|
||||
|
||||
}
|
||||
|
||||
//Called when the task is paused.
|
||||
protected override void OnPause() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 67c9324e429e09f4da157ab85dadacff
|
||||
@@ -0,0 +1,46 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using Reset.Core;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Reset.Units {
|
||||
|
||||
[Category("Reset/Movement")]
|
||||
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.
|
||||
//Return null if init was successfull. Return an error string otherwise
|
||||
protected override string OnInit() {
|
||||
return null;
|
||||
}
|
||||
|
||||
//This is called once each time the task is enabled.
|
||||
//Call EndAction() to mark the action as finished, either in success or failure.
|
||||
//EndAction can be called from anywhere.
|
||||
protected override void OnExecute() {
|
||||
FloatValueGroup.UpdateValue(moveSpeed, agent.data.moveSpeed);
|
||||
FloatValueGroup.UpdateValue(acceleration, agent.data.acceleration);
|
||||
FloatValueGroup.UpdateValue(deacceleration, agent.data.deacceleration);
|
||||
|
||||
EndAction(true);
|
||||
}
|
||||
|
||||
//Called once per frame while the action is active.
|
||||
protected override void OnUpdate() {
|
||||
|
||||
}
|
||||
|
||||
//Called when the task is disabled.
|
||||
protected override void OnStop() {
|
||||
|
||||
}
|
||||
|
||||
//Called when the task is paused.
|
||||
protected override void OnPause() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c1f858e8bdedb4f46ac3e10c0dccde29
|
||||
@@ -1,27 +1,19 @@
|
||||
using System;
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using Reset.Core;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace Reset.Movement {
|
||||
namespace Reset.Units {
|
||||
|
||||
[Category("Reset/Movement")]
|
||||
[Description("Updates the movespeed for this agent")]
|
||||
public class UpdateMovementSpeed : ActionTask{
|
||||
public BBParameter<float> target;
|
||||
public BBParameter<float> speed;
|
||||
public BBParameter<float> smoothing = 10f;
|
||||
|
||||
private float currentSpeed;
|
||||
public class ChangeRotationSettings : ActionTask<UnitMovementHandler> {
|
||||
[SerializeField] public EnumValueGroup facingDirection = new EnumValueGroup("Facing Direction", PlayerFacingDirection.TowardsTarget);
|
||||
[SerializeField] public FloatValueGroup rotationSpeed = new (newLabel: "Rotation Speed");
|
||||
|
||||
//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() {
|
||||
if (!speed.useBlackboard) {
|
||||
Debug.LogError("This <b>Update Movement Speed</b> does not have it's current value attached to a Blackboard variable. Nothing will happen.", agent.gameObject);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -29,22 +21,15 @@ namespace Reset.Movement {
|
||||
//Call EndAction() to mark the action as finished, either in success or failure.
|
||||
//EndAction can be called from anywhere.
|
||||
protected override void OnExecute(){
|
||||
// currentSpeed = speed.value;
|
||||
EnumValueGroup.UpdateValue(facingDirection, agent.data.facingDirection);
|
||||
FloatValueGroup.UpdateValue(rotationSpeed, agent.data.rotationSpeed);
|
||||
|
||||
EndAction(true);
|
||||
}
|
||||
|
||||
//Called once per frame while the action is active.
|
||||
protected override void OnUpdate() {
|
||||
currentSpeed = Mathf.Lerp(currentSpeed, target.value, smoothing.value * Time.deltaTime);
|
||||
|
||||
speed.value = currentSpeed;
|
||||
|
||||
if (Mathf.Abs(currentSpeed - speed.value) < .01f) {
|
||||
|
||||
}
|
||||
|
||||
Debug.Log("Speed Done");
|
||||
EndAction(true);
|
||||
}
|
||||
|
||||
//Called when the task is disabled.
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2af547219746e194f97217fe24cfb8cd
|
||||
@@ -0,0 +1,57 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace Reset.Units {
|
||||
[Category("Reset/Movement")]
|
||||
[Description("Set a new direction value for this agent, either additively, absolutely, or relatively.")]
|
||||
public class SetNewDirection : ActionTask<UnitMovementHandler> {
|
||||
public BBParameter<Vector2> newDirection;
|
||||
[Tooltip("Setting absolute to true will cause the resolved movement direction to snap to the new gravity value. Keeping it false will make it apply additively to the resolved movement direction. Both options use relativty for linear interpolation.")]
|
||||
public BBParameter<bool> absolute;
|
||||
[Tooltip("Higher relativity means more of the new value is used. Value of 1 will set it to the value directly, while .5 will blend halfway between.")]
|
||||
[SliderField(0, 1)]
|
||||
public BBParameter<float> relativity;
|
||||
|
||||
[Tooltip("Setting raw direciton will affect things that read the raw direction like rotation")]
|
||||
public BBParameter<bool> setRawAsWell;
|
||||
|
||||
[Tooltip("This is set as a Vector3 but will be translated into a Vector2 on execute")]
|
||||
public BBParameter<Vector3> relativeTo;
|
||||
|
||||
//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() {
|
||||
return null;
|
||||
}
|
||||
|
||||
//This is called once each time the task is enabled.
|
||||
//Call EndAction() to mark the action as finished, either in success or failure.
|
||||
//EndAction can be called from anywhere.
|
||||
protected override void OnExecute() {
|
||||
agent.SetNewDirection(newDirection.value, relativity.value, absolute.value, relativeTo.value.ToVector2());
|
||||
|
||||
if (setRawAsWell.value) {
|
||||
agent.SetNewRawDirection(newDirection.value, relativity.value, absolute.value, relativeTo.value.ToVector2());
|
||||
}
|
||||
|
||||
EndAction(true);
|
||||
}
|
||||
|
||||
//Called once per frame while the action is active.
|
||||
protected override void OnUpdate() {
|
||||
|
||||
}
|
||||
|
||||
//Called when the task is disabled.
|
||||
protected override void OnStop() {
|
||||
|
||||
}
|
||||
|
||||
//Called when the task is paused.
|
||||
protected override void OnPause() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fd070de4d2cacf64b8c520e98c8e4138
|
||||
@@ -0,0 +1,45 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Reset.Units {
|
||||
[Category("Reset/Movement")]
|
||||
[Description("Sets a new value for gravity. Additively, or absolutely.")]
|
||||
public class SetNewGravity : ActionTask<UnitMovementHandler>{
|
||||
public BBParameter<float> newGravity;
|
||||
[Tooltip("Setting absolute to true will cause the resolved movement gravity to snap to the new gravity value. Keeping it false will make it apply additively to the resolved movement gravity. Both options use relativty for linear interpolation.")]
|
||||
public BBParameter<bool> absolute;
|
||||
[Tooltip("Higher relativity means more of the new value is used. Value of 1 will set it to the value directly, while .5 will blend halfway between.")]
|
||||
[SliderField(0, 1)]
|
||||
public BBParameter<float> relativity;
|
||||
|
||||
//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() {
|
||||
return null;
|
||||
}
|
||||
|
||||
//This is called once each time the task is enabled.
|
||||
//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() {
|
||||
|
||||
}
|
||||
|
||||
//Called when the task is disabled.
|
||||
protected override void OnStop() {
|
||||
|
||||
}
|
||||
|
||||
//Called when the task is paused.
|
||||
protected override void OnPause() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ebaf22f2865425e4c8f10f444ae83c21
|
||||
@@ -0,0 +1,49 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace Reset.Units {
|
||||
|
||||
[Category("Reset/Movement")]
|
||||
[Description("Set a new rotation value for this agent, either additively, absolutely, or relatively.")]
|
||||
public class SetNewRotation : ActionTask<UnitMovementHandler> {
|
||||
public BBParameter<Quaternion> newRotation;
|
||||
[Tooltip("Setting absolute to true will cause the resolved movement rotation to snap to the new gravity value. Keeping it false will make it apply additively to the resolved movement rotation. Both options use relativty for linear interpolation.")]
|
||||
public BBParameter<bool> absolute;
|
||||
[Tooltip("Higher relativity means more of the new value is used. Value of 1 will set it to the value directly, while .5 will blend halfway between.")]
|
||||
[SliderField(0, 1)]
|
||||
public BBParameter<float> relativity;
|
||||
|
||||
public BBParameter<Quaternion> relativeTo;
|
||||
|
||||
//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() {
|
||||
return null;
|
||||
}
|
||||
|
||||
//This is called once each time the task is enabled.
|
||||
//Call EndAction() to mark the action as finished, either in success or failure.
|
||||
//EndAction can be called from anywhere.
|
||||
protected override void OnExecute() {
|
||||
agent.SetNewRotation(newRotation.value, relativity.value, absolute.value, relativeTo.value);
|
||||
EndAction(true);
|
||||
}
|
||||
|
||||
//Called once per frame while the action is active.
|
||||
protected override void OnUpdate() {
|
||||
|
||||
}
|
||||
|
||||
//Called when the task is disabled.
|
||||
protected override void OnStop() {
|
||||
|
||||
}
|
||||
|
||||
//Called when the task is paused.
|
||||
protected override void OnPause() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 66d712031a5b8834c96bbf7bb79048fb
|
||||
@@ -0,0 +1,47 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace Reset.Units {
|
||||
|
||||
[Category("Reset/Movement")]
|
||||
[Description("Set a new speed value for this agent, either additively, absolutely, or relatively.")]
|
||||
public class SetNewSpeed : ActionTask<UnitMovementHandler> {
|
||||
public BBParameter<float> newSpeed;
|
||||
[Tooltip("Setting absolute to true will cause the resolved movement speed to snap to the new speed value. Keeping it false will make it apply additively to the resolved movement speed. Both options use relativty for linear interpolation.")]
|
||||
public BBParameter<bool> absolute;
|
||||
[Tooltip("Higher relativity means more of the new value is used. Value of 1 will set it to the value directly, while .5 will blend halfway between.")]
|
||||
[SliderField(0, 1)]
|
||||
public BBParameter<float> relativity;
|
||||
|
||||
//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() {
|
||||
return null;
|
||||
}
|
||||
|
||||
//This is called once each time the task is enabled.
|
||||
//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(newSpeed.value, relativity.value, absolute.value);
|
||||
EndAction(true);
|
||||
}
|
||||
|
||||
//Called once per frame while the action is active.
|
||||
protected override void OnUpdate() {
|
||||
|
||||
}
|
||||
|
||||
//Called when the task is disabled.
|
||||
protected override void OnStop() {
|
||||
|
||||
}
|
||||
|
||||
//Called when the task is paused.
|
||||
protected override void OnPause() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 605f812405d9b7d4c87c80ce8e41a056
|
||||
@@ -1,71 +0,0 @@
|
||||
using System;
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using Reset.Movement;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NodeCanvas.Tasks.Actions {
|
||||
|
||||
[Category("Reset/Movement")]
|
||||
[Description("Launch the agent towards a specific point with respect to distance.")]
|
||||
public class StartLaunchJump : ActionTask<CharacterController>{
|
||||
public BBParameter<Vector3> airDirection;
|
||||
public BBParameter<float> jumpPower;
|
||||
|
||||
public BBParameter<Vector3> targetLocation;
|
||||
public BBParameter<Vector3> offset;
|
||||
|
||||
public BBParameter<Vector3> relativeRotation;
|
||||
|
||||
public BBParameter<PlayerFacingDirection> launchRelativeTo;
|
||||
|
||||
|
||||
public BBParameter<bool> useRelativeForce;
|
||||
[ShowIf("useRelativeForce", 1)] public BBParameter<float> minimumForce;
|
||||
[ShowIf("useRelativeForce", 1)] public BBParameter<float> maximumForce;
|
||||
[ShowIf("useRelativeForce", 1)] public BBParameter<float> forceRelativeToDistance;
|
||||
public BBParameter<float> force;
|
||||
|
||||
//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() {
|
||||
return null;
|
||||
}
|
||||
|
||||
//This is called once each time the task is enabled.
|
||||
//Call EndAction() to mark the action as finished, either in success or failure.
|
||||
//EndAction can be called from anywhere.
|
||||
protected override void OnExecute(){
|
||||
Vector3 launchDir = agent.transform.position.DirectionTo(targetLocation.value).normalized;
|
||||
launchDir = Quaternion.Euler(relativeRotation.value) * launchDir;
|
||||
|
||||
Debug.Log(launchDir);
|
||||
|
||||
float distanceToTarget = Vector3.Distance(agent.transform.position, targetLocation.value);
|
||||
|
||||
float outputForce = (useRelativeForce.value ? distanceToTarget * forceRelativeToDistance.value : force.value);
|
||||
|
||||
outputForce = Mathf.Clamp(outputForce, minimumForce.value, maximumForce.value);
|
||||
jumpPower.value = outputForce;
|
||||
|
||||
airDirection.value = (launchDir * outputForce);
|
||||
|
||||
EndAction(true);
|
||||
}
|
||||
|
||||
//Called once per frame while the action is active.
|
||||
protected override void OnUpdate() {
|
||||
|
||||
}
|
||||
|
||||
//Called when the task is disabled.
|
||||
protected override void OnStop() {
|
||||
|
||||
}
|
||||
|
||||
//Called when the task is paused.
|
||||
protected override void OnPause() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f32fe451feb2ca4e8159d4aa8919cd2
|
||||
@@ -1,73 +0,0 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using ParadoxNotion.Services;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Reset.Movement {
|
||||
|
||||
[Category("Reset/Movement")]
|
||||
[Description("Process Y-axis movement for the agent")]
|
||||
// TODO: Rename to UpdateGravitytDirection
|
||||
public class UpdateGravityDirection : ActionTask<CharacterController>{
|
||||
public BBParameter<Vector3> moveDirection;
|
||||
public BBParameter<float> jumpPower;
|
||||
public BBParameter<float> jumpPowerDecay;
|
||||
|
||||
[Space(5)]
|
||||
public BBParameter<float> gravityAcceleration = 1f;
|
||||
public BBParameter<float> gravityMax = 8f;
|
||||
|
||||
public BBParameter<float> gravityPower;
|
||||
|
||||
//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() {
|
||||
MonoManager.current.onLateUpdate += LateUpdate;
|
||||
return null;
|
||||
}
|
||||
|
||||
//This is called once each time the task is enabled.
|
||||
//Call EndAction() to mark the action as finished, either in success or failure.
|
||||
//EndAction can be called from anywhere.
|
||||
protected override void OnExecute() {
|
||||
}
|
||||
|
||||
//Called once per frame while the action is active.
|
||||
protected override void OnUpdate() {
|
||||
// Accelerate gravity
|
||||
gravityPower.value += gravityAcceleration.value * Time.deltaTime;
|
||||
gravityPower.value = Mathf.Min(gravityPower.value, gravityMax.value);
|
||||
|
||||
// Apply a constant gravity if the player is grounded
|
||||
if (agent.isGrounded) {
|
||||
gravityPower.value = .1f;
|
||||
}
|
||||
|
||||
// Create the gravity direction
|
||||
float gravityMoveDirection = jumpPower.value + Physics.gravity.y * gravityPower.value;
|
||||
|
||||
// Commit gravity to move direction, ignoring XZ since those are done in UpdateMovementDirection
|
||||
moveDirection.value = new Vector3(moveDirection.value.x, gravityMoveDirection, moveDirection.value.z);
|
||||
|
||||
Debug.Log("Gravity Done");
|
||||
|
||||
EndAction(true);
|
||||
|
||||
}
|
||||
public void LateUpdate(){
|
||||
// Decay jump power
|
||||
jumpPower.value = Mathf.Lerp(jumpPower.value, 0f, jumpPowerDecay.value * Time.deltaTime);
|
||||
}
|
||||
|
||||
|
||||
//Called when the task is disabled.
|
||||
protected override void OnStop() {
|
||||
|
||||
}
|
||||
|
||||
//Called when the task is paused.
|
||||
protected override void OnPause() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5531fbd949d33204690c98dd89a5e97f
|
||||
@@ -1,118 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using ParadoxNotion.Services;
|
||||
using Unity.Cinemachine;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
using Reset.Movement;
|
||||
using Reset.Units;
|
||||
|
||||
namespace NodeCanvas.Tasks.Actions {
|
||||
|
||||
[Category("Reset/Movement")]
|
||||
[Description("Finalizes movement and sends the final move commands to the controller")]
|
||||
// TODO: Rename to UpdateMovementDirection
|
||||
public class UpdateMovementDirection : ActionTask<CharacterController>{
|
||||
[ParadoxNotion.Design.Header("References")]
|
||||
public BBParameter<Vector3> moveDirection;
|
||||
// TODO: Remove this reference and let each copy of this use their own settings.
|
||||
public BBParameter<PlayerFacingDirection> playerFacingDirection;
|
||||
|
||||
[ParadoxNotion.Design.Header("Settings")]
|
||||
public BBParameter<float> accelerationSmoothing = 5f;
|
||||
public BBParameter<float> deaccelerationSmoothing = 5f;
|
||||
public BBParameter<AnimationCurve> deaccelerationCurve;
|
||||
|
||||
public BBParameter<float> directionChangeMinimumMagnitude; // Unused. Use to only make input change if it's over a certain input threshold. Maybe smoothing can affect this?
|
||||
|
||||
private float lastLookMagnitude;
|
||||
private Vector3 currentMoveDir;
|
||||
|
||||
// References
|
||||
private PlayerControls controls;
|
||||
|
||||
//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() {
|
||||
// Reference to controls
|
||||
controls = agent.GetComponent<PlayerControls>();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
//This is called once each time the task is enabled.
|
||||
//Call EndAction() to mark the action as finished, either in success or failure.
|
||||
//EndAction can be called from anywhere.
|
||||
protected override void OnExecute(){
|
||||
// Initialize the smoothed direction with the value as is on input
|
||||
// currentMoveDir = new Vector3(moveDirection.value.x, moveDirection.value.y, moveDirection.value.z);
|
||||
}
|
||||
|
||||
//Called once per frame while the action is active.
|
||||
protected override void OnUpdate(){
|
||||
// Construct move direction
|
||||
Vector3 targetDirection = moveDirection.value;
|
||||
|
||||
// Get input value
|
||||
Vector3 inputMovement = new Vector3(controls.rawMoveInput.x, 0f, controls.rawMoveInput.y);
|
||||
|
||||
if (inputMovement.magnitude < .1f) {
|
||||
inputMovement = Vector3.zero;
|
||||
}
|
||||
|
||||
// Change how movement is managed based on facing state
|
||||
switch (playerFacingDirection.value) {
|
||||
case PlayerFacingDirection.TowardsTarget:
|
||||
break;
|
||||
case PlayerFacingDirection.MatchForward: // TODO: Recomment
|
||||
// targetDirection = agent.transform.forward * inputMovement.magnitude;
|
||||
targetDirection = inputMovement;
|
||||
break;
|
||||
case PlayerFacingDirection.MatchCamera:
|
||||
targetDirection = Quaternion.Euler(Camera.main.transform.forward.DirectionTo(agent.transform.forward)) * inputMovement; // NOTE: This used to be t: currentRotSpeed * Time.deltaTime.
|
||||
// See how it feels with a hard set value and go fro there.
|
||||
break;
|
||||
case PlayerFacingDirection.Static:
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
// Remove Y from variables
|
||||
Vector3 targetNoY = new Vector3(targetDirection.x, 0f, targetDirection.z);
|
||||
Vector3 currentNoY = new Vector3(currentMoveDir.x, 0f, currentMoveDir.z);
|
||||
|
||||
// Smooth movement
|
||||
if (targetNoY.magnitude > currentNoY.magnitude) {
|
||||
currentMoveDir = Vector3.Lerp(currentMoveDir, targetNoY,accelerationSmoothing.value * Time.deltaTime);
|
||||
|
||||
} else {
|
||||
float deaccelValue = deaccelerationCurve.value.Evaluate(inputMovement.magnitude);
|
||||
|
||||
currentMoveDir = Vector3.Lerp(currentMoveDir, targetNoY, deaccelerationSmoothing.value * Time.deltaTime);
|
||||
}
|
||||
|
||||
|
||||
currentMoveDir.y = moveDirection.value.y;
|
||||
// Commit move direction
|
||||
moveDirection.value = currentMoveDir;
|
||||
// Debug.Log(moveDirection.value);
|
||||
EndAction(true);
|
||||
}
|
||||
|
||||
// Gravity is processed in LateUpdate (added to MonoManager's onLateUpdate in OnInit())
|
||||
|
||||
|
||||
//Called when the task is disabled.
|
||||
protected override void OnStop() {
|
||||
EndAction(true);
|
||||
}
|
||||
|
||||
//Called when the task is paused.
|
||||
protected override void OnPause() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 69daf571854fd8046a60a7baab64cc18
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6a4c5896d783ad845861edd0c9eea14b
|
||||
@@ -13,7 +13,49 @@ public static class MathExtensions{
|
||||
return (to - origin).normalized;
|
||||
}
|
||||
|
||||
public static Vector3 ToVector3(this Vector2 vector2){
|
||||
return new Vector3(vector2.x, 0f, vector2.y);
|
||||
}
|
||||
|
||||
public static Vector2 ToVector2(this Vector3 vector3){
|
||||
return new Vector2(vector3.x, vector3.z);
|
||||
}
|
||||
|
||||
public static Color Alpha(this Color input, float newAlpha){
|
||||
return new Color(input.r, input.g, input.b, newAlpha);
|
||||
}
|
||||
|
||||
public static Quaternion SmoothDamp(Quaternion rot, Quaternion target, ref Quaternion deriv, float time) {
|
||||
if (Time.deltaTime < Mathf.Epsilon) return rot;
|
||||
// account for double-cover
|
||||
var Dot = Quaternion.Dot(rot, target);
|
||||
var Multi = Dot > 0f ? 1f : -1f;
|
||||
target.x *= Multi;
|
||||
target.y *= Multi;
|
||||
target.z *= Multi;
|
||||
target.w *= Multi;
|
||||
// smooth damp (nlerp approx)
|
||||
var Result = new Vector4(
|
||||
Mathf.SmoothDamp(rot.x, target.x, ref deriv.x, time),
|
||||
Mathf.SmoothDamp(rot.y, target.y, ref deriv.y, time),
|
||||
Mathf.SmoothDamp(rot.z, target.z, ref deriv.z, time),
|
||||
Mathf.SmoothDamp(rot.w, target.w, ref deriv.w, time)
|
||||
).normalized;
|
||||
|
||||
// ensure deriv is tangent
|
||||
var derivError = Vector4.Project(new Vector4(deriv.x, deriv.y, deriv.z, deriv.w), Result);
|
||||
deriv.x -= derivError.x;
|
||||
deriv.y -= derivError.y;
|
||||
deriv.z -= derivError.z;
|
||||
deriv.w -= derivError.w;
|
||||
|
||||
return new Quaternion(Result.x, Result.y, Result.z, Result.w);
|
||||
}
|
||||
|
||||
public static Vector2 Rotate(this Vector2 v, float delta) {
|
||||
return new Vector2(
|
||||
v.x * Mathf.Cos(delta) - v.y * Mathf.Sin(delta),
|
||||
v.x * Mathf.Sin(delta) + v.y * Mathf.Cos(delta)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
482
Assets/Scripts/Core/ValueGroupEditors.cs
Normal file
482
Assets/Scripts/Core/ValueGroupEditors.cs
Normal file
@@ -0,0 +1,482 @@
|
||||
using NodeCanvas.Editor;
|
||||
using ParadoxNotion.Design;
|
||||
using Reset.Core;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public class BoolValueGroupDrawer : ObjectDrawer<BoolValueGroup> {
|
||||
public override BoolValueGroup OnGUI(GUIContent _content, BoolValueGroup _instance){
|
||||
// Remove label for floats
|
||||
EditorGUIUtility.labelWidth = 50;
|
||||
|
||||
// Set layout options for the label and the float fields
|
||||
GUILayoutOption[] floatOptions = new GUILayoutOption[] {
|
||||
GUILayout.Width(80.0f),
|
||||
GUILayout.MinWidth(20.0f),
|
||||
GUILayout.ExpandWidth(true),
|
||||
};
|
||||
|
||||
// Start the Vertical layout then add the label before adding a horizontal so the label will be on top of side-by-side options
|
||||
GUILayout.BeginVertical();
|
||||
GUILayout.Label(_instance.label, ValueGroupEditorUtilities.titleText);
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
// Create the x settings enum
|
||||
_instance.changeValue = (ValueChangeAction)EditorGUILayout.EnumPopup("", instance.changeValue.value);
|
||||
|
||||
// Create the value/disabled information field
|
||||
if (_instance.changeValue.value == ValueChangeAction.NewValue){
|
||||
_instance.value = EditorGUILayout.Toggle(_instance.value.value, floatOptions);
|
||||
} else if (_instance.changeValue.value == ValueChangeAction.RelativeValue){
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
EditorGUILayout.TextField("Not Available", floatOptions);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
} else {
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
EditorGUILayout.TextField(_instance.changeValue.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
|
||||
// Close this line up
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.EndVertical();
|
||||
|
||||
// Reset to default so the rest of things don't get messed up
|
||||
EditorGUIUtility.labelWidth = 0;
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class CurveValueGroupDrawer : ObjectDrawer<CurveValueGroup> {
|
||||
public override CurveValueGroup OnGUI(GUIContent _content, CurveValueGroup _instance){
|
||||
// Remove label for floats
|
||||
EditorGUIUtility.labelWidth = 50;
|
||||
|
||||
// Set layout options for the label and the float fields
|
||||
GUILayoutOption[] floatOptions = new GUILayoutOption[] {
|
||||
GUILayout.Width(80.0f),
|
||||
GUILayout.MinWidth(20.0f),
|
||||
GUILayout.ExpandWidth(true),
|
||||
};
|
||||
|
||||
// Start the Vertical layout then add the label before adding a horizontal so the label will be on top of side-by-side options
|
||||
GUILayout.BeginVertical();
|
||||
GUILayout.Label(_instance.label, ValueGroupEditorUtilities.titleText);
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
// Create the x settings enum
|
||||
_instance.changeValue.value = (ValueChangeAction)EditorGUILayout.EnumPopup("", instance.changeValue.value);
|
||||
|
||||
// Create the value/disabled information field
|
||||
if (_instance.changeValue.value == ValueChangeAction.NewValue){
|
||||
BBParameterEditor.ParameterField("", _instance.value);
|
||||
} else {
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
EditorGUILayout.TextField(_instance.changeValue.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
|
||||
// Close this line up
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.EndVertical();
|
||||
|
||||
// Reset to default so the rest of things don't get messed up
|
||||
EditorGUIUtility.labelWidth = 0;
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
public class EnumValueGroupDrawer : ObjectDrawer<EnumValueGroup>{
|
||||
public override EnumValueGroup OnGUI(GUIContent _content, EnumValueGroup _instance){
|
||||
// Set layout options for the label and the float fields
|
||||
GUILayoutOption[] floatOptions = new GUILayoutOption[] {
|
||||
GUILayout.Width(200.0f),
|
||||
GUILayout.MinWidth(100.0f),
|
||||
GUILayout.ExpandWidth(true),
|
||||
};
|
||||
|
||||
|
||||
// Start the Vertical layout then add the label before adding a horizontal so the label will be on top of side-by-side options
|
||||
GUILayout.BeginVertical();
|
||||
GUILayout.Label(_instance.label, ValueGroupEditorUtilities.titleText);
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
// Create the x settings enum
|
||||
_instance.changeValue.value = (ValueChangeAction)EditorGUILayout.EnumPopup("", instance.changeValue.value);
|
||||
|
||||
// Create the value/disabled information field
|
||||
if (_instance.changeValue.value == ValueChangeAction.NewValue){
|
||||
_instance.value.value = EditorGUILayout.EnumPopup("", instance.value.value, floatOptions);
|
||||
} else {
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
EditorGUILayout.TextField((ValueChangeAction)_instance.value.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
|
||||
// Close this line up
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.EndVertical();
|
||||
|
||||
// Reset to default so the rest of things don't get messed up
|
||||
EditorGUIUtility.labelWidth = 0;
|
||||
return _instance;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class FloatValueGroupDrawer : ObjectDrawer<FloatValueGroup> {
|
||||
public override FloatValueGroup OnGUI(GUIContent _content, FloatValueGroup _instance){
|
||||
// Remove label for floats
|
||||
EditorGUIUtility.labelWidth = 50;
|
||||
|
||||
// Start the label
|
||||
GUILayout.BeginHorizontal();
|
||||
// Set layout options for the label and the float fields
|
||||
GUILayoutOption[] floatOptions = new GUILayoutOption[] {
|
||||
GUILayout.Width(80.0f),
|
||||
GUILayout.MinWidth(20.0f),
|
||||
GUILayout.ExpandWidth(true),
|
||||
};
|
||||
|
||||
// Start the Vertical layout then add the label before adding a horizontal so the label will be on top of side-by-side options
|
||||
GUILayout.Label(_instance.label, ValueGroupEditorUtilities.titleText);
|
||||
|
||||
// End the label
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
// Start the variables
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
// Create the x settings enum
|
||||
// _instance.changeValue.value = (ValueChangeAction)EditorGUILayout.EnumPopup("", instance.changeValue.value);
|
||||
BBParameterEditor.ParameterField("", _instance.changeValue);
|
||||
|
||||
// Create the value/disabled information field
|
||||
if (_instance.changeValue.value == ValueChangeAction.NewValue || _instance.changeValue.value == ValueChangeAction.RelativeValue){
|
||||
BBParameterEditor.ParameterField("", _instance.value);
|
||||
} else {
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
EditorGUILayout.TextField(_instance.changeValue.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
|
||||
// Close this line up with the variables
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
ValueGroupEditorUtilities.DrawEasingAndSmoothingSection(_instance);
|
||||
|
||||
// Reset to default so the rest of things don't get messed up
|
||||
EditorGUIUtility.labelWidth = 0;
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
public class Vector3ValueGroupDrawer : ObjectDrawer<Vector3ValueGroup> {
|
||||
public override Vector3ValueGroup OnGUI(GUIContent _content, Vector3ValueGroup _instance){
|
||||
// Remove label for floats
|
||||
EditorGUIUtility.labelWidth = 20;
|
||||
|
||||
// Set layout options for the label and the float fields
|
||||
GUILayoutOption[] floatOptions = new GUILayoutOption[] {
|
||||
GUILayout.Width(300.0f),
|
||||
GUILayout.MinWidth(20.0f),
|
||||
GUILayout.ExpandWidth(true),
|
||||
};
|
||||
|
||||
// Start the Vertical layout then add the label before adding a horizontal so the label will be on top of side-by-side options
|
||||
GUILayout.BeginVertical();
|
||||
GUILayout.Label(_instance.label, ValueGroupEditorUtilities.titleText);
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
// Create the x settings enum
|
||||
_instance.changeX.value = (ValueChangeAction)EditorGUILayout.EnumPopup("", instance.changeX.value);
|
||||
|
||||
// Create the value/disabled information field
|
||||
if (_instance.changeX.value== ValueChangeAction.NewValue) {
|
||||
var value = _instance.value.value;
|
||||
value.x = EditorGUILayout.FloatField(_instance.value.value.x, floatOptions);
|
||||
_instance.value.value = value;
|
||||
} else {
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
EditorGUILayout.TextField(_instance.changeX.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
|
||||
// It do what it do.
|
||||
GUILayout.Space(5);
|
||||
|
||||
// Create the y settings enum
|
||||
_instance.changeY.value = (ValueChangeAction)EditorGUILayout.EnumPopup("", _instance.changeY.value);
|
||||
|
||||
// Create the value/disabled information field
|
||||
if (_instance.changeY.value == ValueChangeAction.NewValue) {
|
||||
var value = _instance.value.value;
|
||||
value.y = EditorGUILayout.FloatField(_instance.value.value.y, floatOptions);
|
||||
_instance.value.value = value;
|
||||
} else {
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
EditorGUILayout.TextField(_instance.changeY.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
|
||||
// It do what it do.
|
||||
GUILayout.Space(5);
|
||||
|
||||
// Create the y settings enum
|
||||
_instance.changeZ.value = (ValueChangeAction)EditorGUILayout.EnumPopup("", _instance.changeZ.value);
|
||||
|
||||
// Create the value/disabled information field
|
||||
if (_instance.changeZ.value == ValueChangeAction.NewValue) {
|
||||
var value = _instance.value.value;
|
||||
value.z = EditorGUILayout.FloatField(_instance.value.value.z, floatOptions);
|
||||
_instance.value.value = value;
|
||||
} else {
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
EditorGUILayout.TextField(_instance.changeZ.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
|
||||
// Close this line up
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
ValueGroupEditorUtilities.DrawEasingAndSmoothingSection(_instance);
|
||||
|
||||
GUILayout.EndVertical();
|
||||
|
||||
// Reset to default so the rest of things don't get messed up
|
||||
EditorGUIUtility.labelWidth = 0;
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
public class Vector2ValueGroupDrawer : ObjectDrawer<Vector2ValueGroup> {
|
||||
public override Vector2ValueGroup OnGUI(GUIContent _content, Vector2ValueGroup _instance){
|
||||
// Remove label for floats
|
||||
EditorGUIUtility.labelWidth = 50;
|
||||
|
||||
// Set layout options for the label and the float fields
|
||||
GUILayoutOption[] floatOptions = new GUILayoutOption[] {
|
||||
GUILayout.Width(300.0f),
|
||||
GUILayout.MinWidth(20.0f),
|
||||
GUILayout.ExpandWidth(true),
|
||||
};
|
||||
|
||||
// Start the Vertical layout then add the label before adding a horizontal so the label will be on top of side-by-side options
|
||||
GUILayout.BeginVertical();
|
||||
GUILayout.Label(_instance.label, ValueGroupEditorUtilities.titleText);
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
// Create the x settings enum
|
||||
_instance.changeX.value = (ValueChangeAction)EditorGUILayout.EnumPopup("", instance.changeX.value);
|
||||
|
||||
// Create the value/disabled information field
|
||||
if (_instance.changeX.value == ValueChangeAction.NewValue) {
|
||||
var value = _instance.value.value;
|
||||
value.x = EditorGUILayout.FloatField(_instance.value.value.x, floatOptions);
|
||||
_instance.value.value = value;
|
||||
} else {
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
EditorGUILayout.TextField(_instance.changeX.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
|
||||
// It do what it do.
|
||||
GUILayout.Space(5);
|
||||
|
||||
// Create the y settings enum
|
||||
_instance.changeY.value = (ValueChangeAction)EditorGUILayout.EnumPopup("", _instance.changeY.value);
|
||||
|
||||
// Create the value/disabled information field
|
||||
if (_instance.changeY.value == ValueChangeAction.NewValue) {
|
||||
var value = _instance.value.value;
|
||||
value.y = EditorGUILayout.FloatField(_instance.value.value.y, floatOptions);
|
||||
_instance.value.value = value;
|
||||
} else {
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
EditorGUILayout.TextField(_instance.changeY.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
|
||||
// Close this line up
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
ValueGroupEditorUtilities.DrawEasingAndSmoothingSection(_instance);
|
||||
|
||||
GUILayout.EndVertical();
|
||||
|
||||
// Reset to default so the rest of things don't get messed up
|
||||
EditorGUIUtility.labelWidth = 0;
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
// Custom editor for each orbital follow ring setting
|
||||
public class OrbitalFollowValueGroupDrawer : ObjectDrawer<OrbitalFollowValueGroup>{
|
||||
public override OrbitalFollowValueGroup OnGUI(GUIContent _content, OrbitalFollowValueGroup _instance){
|
||||
// Remove label for floats
|
||||
EditorGUIUtility.labelWidth = 1;
|
||||
|
||||
// Set layout options for the label and the float fields
|
||||
GUILayoutOption[] floatOptions = new GUILayoutOption[] {
|
||||
// GUILayout.Width(300.0f),
|
||||
// GUILayout.MinWidth(20.0f),
|
||||
GUILayout.ExpandWidth(true),
|
||||
};
|
||||
|
||||
// Add the label
|
||||
GUILayout.Label(_instance.label, ValueGroupEditorUtilities.titleText);
|
||||
|
||||
// Start the smoothing and easing section
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
GUIStyle smallText= new GUIStyle{
|
||||
fontSize = 10,
|
||||
padding = new RectOffset(8, 0, 0,0),
|
||||
normal ={
|
||||
textColor = Color.gray + Color.gray / 2f
|
||||
}
|
||||
};
|
||||
|
||||
// Start the left side for height
|
||||
GUILayout.BeginVertical();
|
||||
|
||||
// Draw the label
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("Height", smallText);
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
// Height
|
||||
BBParameterEditor.ParameterField("", _instance.changeHeight);
|
||||
|
||||
if (_instance.changeHeight.value == ValueChangeAction.NewValue || _instance.changeHeight.value == ValueChangeAction.RelativeValue){
|
||||
// _instance.value = EditorGUILayout.FloatField(_instance.value, floatOptions);
|
||||
BBParameterEditor.ParameterField("", _instance.height);
|
||||
} else {
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
EditorGUILayout.TextField(_instance.changeHeight.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
|
||||
// Close height
|
||||
GUILayout.EndVertical();
|
||||
|
||||
// Start the right for radius
|
||||
GUILayout.BeginVertical();
|
||||
|
||||
// Draw the label
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("Radius", smallText);
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
// Radius
|
||||
BBParameterEditor.ParameterField("", _instance.changeRadius);
|
||||
|
||||
if (_instance.changeRadius.value == ValueChangeAction.NewValue || _instance.changeRadius.value == ValueChangeAction.RelativeValue){
|
||||
// _instance.value = EditorGUILayout.FloatField(_instance.value, floatOptions);
|
||||
BBParameterEditor.ParameterField("", _instance.radius);
|
||||
} else {
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
EditorGUILayout.TextField(_instance.changeRadius.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
|
||||
// Close easing
|
||||
GUILayout.EndVertical();
|
||||
|
||||
GUILayout.Space(8);
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
ValueGroupEditorUtilities.DrawEasingAndSmoothingSection(_instance);
|
||||
|
||||
// Reset to default so the rest of things don't get messed up
|
||||
EditorGUIUtility.labelWidth = 0;
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ValueGroupEditorUtilities{
|
||||
public static void DrawEasingAndSmoothingSection(ValueGroup.ISmoothable _instance){
|
||||
// Start the smoothing and easing section
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
GUIStyle smallText= new GUIStyle{
|
||||
fontSize = 10,
|
||||
padding = new RectOffset(8, 0, 0,0),
|
||||
normal ={
|
||||
textColor = Color.gray
|
||||
}
|
||||
};
|
||||
|
||||
// Start the left side for easing
|
||||
GUILayout.BeginVertical();
|
||||
|
||||
// Draw the label
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("Easing", smallText);
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
// Easing
|
||||
// _instance.changeEasing.value = (ValueChangeAction)EditorGUILayout.EnumPopup("", instance.changeEasing.value);
|
||||
BBParameterEditor.ParameterField("", _instance.changeEasing);
|
||||
|
||||
if (_instance.changeEasing.value == ValueChangeAction.NewValue){
|
||||
// _instance.value = EditorGUILayout.FloatField(_instance.value, floatOptions);
|
||||
BBParameterEditor.ParameterField("", _instance.Easing);
|
||||
} else {
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
EditorGUILayout.TextField(_instance.changeEasing.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
|
||||
// Close easing
|
||||
GUILayout.EndVertical();
|
||||
|
||||
// Start the right for smoothing
|
||||
GUILayout.BeginVertical();
|
||||
|
||||
// Draw the label
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("Smoothing", smallText);
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
// Smoothing
|
||||
BBParameterEditor.ParameterField("", _instance.changeSmoothing);
|
||||
|
||||
if (_instance.changeSmoothing.value == ValueChangeAction.NewValue){
|
||||
// _instance.value = EditorGUILayout.FloatField(_instance.value, floatOptions);
|
||||
BBParameterEditor.ParameterField("", _instance.Smoothing);
|
||||
} else {
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
EditorGUILayout.TextField(_instance.changeSmoothing.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
|
||||
// Close easing
|
||||
GUILayout.EndVertical();
|
||||
|
||||
GUILayout.Space(8);
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
static GUILayoutOption[] floatOptions = new GUILayoutOption[] {
|
||||
GUILayout.Width(300.0f),
|
||||
GUILayout.MinWidth(20.0f),
|
||||
GUILayout.ExpandWidth(true),
|
||||
};
|
||||
|
||||
public static GUIStyle titleText = new GUIStyle{
|
||||
fontSize = 12,
|
||||
fontStyle = FontStyle.Bold,
|
||||
padding = new RectOffset(8, 0, 3,0),
|
||||
normal ={
|
||||
textColor = Color.white
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
||||
3
Assets/Scripts/Core/ValueGroupEditors.cs.meta
Normal file
3
Assets/Scripts/Core/ValueGroupEditors.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e327ef0e278a437486396775f36450dd
|
||||
timeCreated: 1758039991
|
||||
55
Assets/Scripts/Player/CameraSettingData.cs
Normal file
55
Assets/Scripts/Player/CameraSettingData.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
public class CameraSettingData{
|
||||
[Title("Field of View"), HideLabel, InlineProperty] public SettingValue<float> mainFieldOfView = new SettingValue<float>(0f);
|
||||
|
||||
[Title("Orbit Position Damping"), HideLabel, InlineProperty] public SettingValue<Vector3> orbitPositionDamping = new SettingValue<Vector3>(Vector3.zero);
|
||||
[Title("Orbit Target Offset"), HideLabel, InlineProperty] public SettingValue<Vector3> orbitTargetOffset= new SettingValue<Vector3>(Vector3.zero);
|
||||
|
||||
[Title("X Axis Look Enabled"), HideLabel, InlineProperty] public SettingValue<bool> axisLookEnabledX = new SettingValue<bool>(true);
|
||||
[Title("Y Axis Look Enabled"), HideLabel, InlineProperty] public SettingValue<bool> axisLookEnabledY = new SettingValue<bool>(true);
|
||||
|
||||
[Title("X Axis Look Gain"), HideLabel, InlineProperty] public SettingValue<float> axisLookGainX = new SettingValue<float>(0f);
|
||||
[Title("Y Axis Look Gain"), HideLabel, InlineProperty] public SettingValue<float> axisLookGainY = new SettingValue<float>(0f);
|
||||
|
||||
[Title("Orbit Follow Top Height"), HideLabel, InlineProperty] public SettingValue<float> orbitFollowTopHeight = new SettingValue<float>(0f);
|
||||
[Title("Orbit Follow Top Radius"), HideLabel, InlineProperty] public SettingValue<float> orbitFollowTopRadius = new SettingValue<float>(0f);
|
||||
[Title("Orbit Follow Center Height"), HideLabel, InlineProperty] public SettingValue<float> orbitFollowCenterHeight = new SettingValue<float>(0f);
|
||||
[Title("Orbit Follow Center Radius"), HideLabel, InlineProperty] public SettingValue<float> orbitFollowCenterRadius = new SettingValue<float>(0f);
|
||||
[Title("Orbit Follow Bottom Height"), HideLabel, InlineProperty] public SettingValue<float> orbitFollowBottomHeight = new SettingValue<float>(0f);
|
||||
[Title("Orbit Follow Bottom Radius"), HideLabel, InlineProperty] public SettingValue<float> orbitFollowBottomRadius = new SettingValue<float>(0f);
|
||||
|
||||
public SettingValue<Vector2> rotationComposerScreenPos= new SettingValue<Vector2>(Vector2.zero);
|
||||
|
||||
public SettingValue<Vector3> cameraOffsetOffset= new SettingValue<Vector3>(Vector3.zero);
|
||||
|
||||
public List<IResettableSettingValue> GetAllSettings(){
|
||||
var outputList = new List<IResettableSettingValue>();
|
||||
|
||||
IResettableSettingValue[] settings = {
|
||||
mainFieldOfView,
|
||||
orbitPositionDamping,
|
||||
orbitTargetOffset,
|
||||
axisLookEnabledX,
|
||||
axisLookEnabledY,
|
||||
axisLookGainX,
|
||||
axisLookGainY,
|
||||
orbitFollowTopHeight,
|
||||
orbitFollowTopRadius,
|
||||
orbitFollowCenterHeight,
|
||||
orbitFollowCenterRadius,
|
||||
orbitFollowBottomHeight,
|
||||
orbitFollowBottomRadius,
|
||||
rotationComposerScreenPos,
|
||||
cameraOffsetOffset,
|
||||
};
|
||||
|
||||
outputList.AddRange(settings);
|
||||
|
||||
return outputList;
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Player/CameraSettingData.cs.meta
Normal file
3
Assets/Scripts/Player/CameraSettingData.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 14393bffe6324344b5f972412e37a339
|
||||
timeCreated: 1758568723
|
||||
@@ -1,82 +1,14 @@
|
||||
using System;
|
||||
using Reset.Core;
|
||||
using Sirenix.OdinInspector;
|
||||
using Unity.Cinemachine;
|
||||
using UnityEngine;
|
||||
|
||||
public struct CameraSettingSingleValue<T>{
|
||||
// NOTE: Could add a locked variable here if needed??
|
||||
public T originalValue;
|
||||
public T targetValue;
|
||||
public float smoothing;
|
||||
|
||||
public float velocityRef;
|
||||
public Vector2 velocityRefV2;
|
||||
public Vector3 velocityRefV3;
|
||||
|
||||
public CameraSettingSingleValue(float defaultSmoothing = .2f, T original = default(T)){
|
||||
originalValue = original;
|
||||
targetValue = original;
|
||||
smoothing = defaultSmoothing;
|
||||
|
||||
velocityRef = 0;
|
||||
velocityRefV2 = default;
|
||||
velocityRefV3 = default;
|
||||
}
|
||||
|
||||
public void Reset(){
|
||||
targetValue = originalValue;
|
||||
}
|
||||
}
|
||||
|
||||
public struct CameraSettingValues{
|
||||
public CameraSettingSingleValue<float> mainFieldOfView;
|
||||
|
||||
public CameraSettingSingleValue<Vector3> orbitPositionDamping;
|
||||
public CameraSettingSingleValue<Vector3> orbitTargetOffset;
|
||||
|
||||
public CameraSettingSingleValue<bool> axisLookEnabledX;
|
||||
public CameraSettingSingleValue<bool> axisLookEnabledY;
|
||||
|
||||
public CameraSettingSingleValue<float> axisLookGainX;
|
||||
public CameraSettingSingleValue<float> axisLookGainY;
|
||||
|
||||
public CameraSettingSingleValue<float> orbitFollowTopHeight;
|
||||
public CameraSettingSingleValue<float> orbitFollowTopRadius;
|
||||
public CameraSettingSingleValue<float> orbitFollowCenterHeight;
|
||||
public CameraSettingSingleValue<float> orbitFollowCenterRadius;
|
||||
public CameraSettingSingleValue<float> orbitFollowBottomHeight;
|
||||
public CameraSettingSingleValue<float> orbitFollowBottomRadius;
|
||||
|
||||
public CameraSettingSingleValue<Vector2> rotationComposerScreenPos;
|
||||
|
||||
public CameraSettingSingleValue<Vector3> cameraOffsetOffset;
|
||||
|
||||
public CameraSettingValues(float defaultSmoothing){
|
||||
mainFieldOfView = new CameraSettingSingleValue<float>(defaultSmoothing);
|
||||
|
||||
orbitPositionDamping = new CameraSettingSingleValue<Vector3>(defaultSmoothing);
|
||||
orbitTargetOffset = new CameraSettingSingleValue<Vector3>(defaultSmoothing);
|
||||
|
||||
axisLookEnabledX = new CameraSettingSingleValue<bool>();
|
||||
axisLookEnabledY = new CameraSettingSingleValue<bool>();
|
||||
|
||||
axisLookGainX = new CameraSettingSingleValue<float>(defaultSmoothing);
|
||||
axisLookGainY = new CameraSettingSingleValue<float>(defaultSmoothing);
|
||||
|
||||
orbitFollowTopHeight = new CameraSettingSingleValue<float>(defaultSmoothing);
|
||||
orbitFollowTopRadius = new CameraSettingSingleValue<float>(defaultSmoothing);
|
||||
orbitFollowCenterHeight = new CameraSettingSingleValue<float>(defaultSmoothing);
|
||||
orbitFollowCenterRadius = new CameraSettingSingleValue<float>(defaultSmoothing);
|
||||
orbitFollowBottomHeight = new CameraSettingSingleValue<float>(defaultSmoothing);
|
||||
orbitFollowBottomRadius = new CameraSettingSingleValue<float>(defaultSmoothing);
|
||||
|
||||
rotationComposerScreenPos = new CameraSettingSingleValue<Vector2>(defaultSmoothing);
|
||||
cameraOffsetOffset = new CameraSettingSingleValue<Vector3>(defaultSmoothing);
|
||||
}
|
||||
}
|
||||
|
||||
public class CameraSettingsProcessor : MonoBehaviour{
|
||||
public static CameraSettingsProcessor Instance{ get; private set; }
|
||||
|
||||
public static CameraSettingValues values = new(defaultSmoothing: .2f);
|
||||
[ShowInInspector, FoldoutGroup("Camera Data", expanded: true), InlineProperty, HideLabel]
|
||||
public CameraSettingData data;
|
||||
|
||||
public static GameObject mainCamera;
|
||||
|
||||
@@ -102,87 +34,81 @@ public class CameraSettingsProcessor : MonoBehaviour{
|
||||
offset = mainCamera.GetComponent<CinemachineCameraOffset>();
|
||||
axisCont = mainCamera.GetComponent<CinemachineInputAxisController>();
|
||||
|
||||
// Initialize camera settings values
|
||||
values = new CameraSettingValues{
|
||||
cameraOffsetOffset = new CameraSettingSingleValue<Vector3>(defaultSmoothing: .2f, offset.Offset),
|
||||
mainFieldOfView = new CameraSettingSingleValue<float>(defaultSmoothing: .2f, main.Lens.FieldOfView),
|
||||
axisLookEnabledX = new CameraSettingSingleValue<bool>(0, axisCont.Controllers[0].Enabled),
|
||||
axisLookEnabledY = new CameraSettingSingleValue<bool>(0, axisCont.Controllers[1].Enabled),
|
||||
axisLookGainX = new CameraSettingSingleValue<float>(defaultSmoothing: .2f, axisCont.Controllers[0].Input.Gain),
|
||||
axisLookGainY = new CameraSettingSingleValue<float>(defaultSmoothing: .2f, axisCont.Controllers[1].Input.Gain),
|
||||
orbitPositionDamping = new CameraSettingSingleValue<Vector3>(defaultSmoothing: .2f, orbit.TrackerSettings.PositionDamping),
|
||||
orbitTargetOffset = new CameraSettingSingleValue<Vector3>(defaultSmoothing: .1f, orbit.TargetOffset),
|
||||
orbitFollowTopHeight = new CameraSettingSingleValue<float>(defaultSmoothing: .2f, orbit.Orbits.Top.Height),
|
||||
orbitFollowTopRadius = new CameraSettingSingleValue<float>(defaultSmoothing: .2f, orbit.Orbits.Top.Radius),
|
||||
orbitFollowCenterHeight = new CameraSettingSingleValue<float>(defaultSmoothing: .2f, orbit.Orbits.Center.Height),
|
||||
orbitFollowCenterRadius = new CameraSettingSingleValue<float>(defaultSmoothing: .2f, orbit.Orbits.Center.Radius),
|
||||
orbitFollowBottomHeight = new CameraSettingSingleValue<float>(defaultSmoothing: .2f, orbit.Orbits.Bottom.Height),
|
||||
orbitFollowBottomRadius = new CameraSettingSingleValue<float>(defaultSmoothing: .2f, orbit.Orbits.Bottom.Radius),
|
||||
rotationComposerScreenPos = new CameraSettingSingleValue<Vector2>(defaultSmoothing: .2f, rotComp.Composition.ScreenPosition),
|
||||
};
|
||||
// Quick check for a camera settings
|
||||
if (data == null) {
|
||||
Debug.LogWarning("No Camera Settings Data was found on processing. One will be created. Is this intentional? This will have strong effects on camera movement");
|
||||
data = new CameraSettingData();
|
||||
}
|
||||
|
||||
void ProcessCameraValues(){
|
||||
main.Lens.FieldOfView = Mathf.SmoothDamp(main.Lens.FieldOfView,
|
||||
values.mainFieldOfView.targetValue, ref values.mainFieldOfView.velocityRef,
|
||||
values.mainFieldOfView.smoothing);
|
||||
|
||||
axisCont.Controllers[0].Enabled = values.axisLookEnabledX.targetValue;
|
||||
|
||||
axisCont.Controllers[1].Enabled = values.axisLookEnabledY.targetValue;
|
||||
|
||||
axisCont.Controllers[0].Input.Gain = Mathf.SmoothDamp(axisCont.Controllers[0].Input.Gain,
|
||||
values.axisLookGainX.targetValue, ref values.axisLookGainX.velocityRef,
|
||||
values.axisLookGainX.smoothing);
|
||||
|
||||
axisCont.Controllers[1].Input.Gain = Mathf.SmoothDamp(axisCont.Controllers[1].Input.Gain,
|
||||
values.axisLookGainY.targetValue, ref values.axisLookGainY.velocityRef,
|
||||
values.axisLookGainY.smoothing);
|
||||
|
||||
orbit.TargetOffset = Vector3.SmoothDamp(orbit.TargetOffset,
|
||||
values.orbitTargetOffset.targetValue, ref values.orbitTargetOffset.velocityRefV3,
|
||||
values.orbitTargetOffset.smoothing);
|
||||
|
||||
orbit.TrackerSettings.PositionDamping = Vector3.SmoothDamp(orbit.TrackerSettings.PositionDamping,
|
||||
values.orbitPositionDamping.targetValue, ref values.orbitPositionDamping.velocityRefV3,
|
||||
values.orbitPositionDamping.smoothing);
|
||||
|
||||
orbit.Orbits.Top.Height = Mathf.SmoothDamp(orbit.Orbits.Top.Height,
|
||||
values.orbitFollowTopHeight.targetValue, ref values.orbitFollowTopHeight.velocityRef,
|
||||
values.orbitFollowTopHeight.smoothing);
|
||||
|
||||
orbit.Orbits.Top.Radius = Mathf.SmoothDamp(orbit.Orbits.Top.Radius,
|
||||
values.orbitFollowTopRadius.targetValue, ref values.orbitFollowTopRadius.velocityRef,
|
||||
values.orbitFollowTopRadius.smoothing);
|
||||
|
||||
orbit.Orbits.Center.Height = Mathf.SmoothDamp(orbit.Orbits.Center.Height,
|
||||
values.orbitFollowCenterHeight.targetValue, ref values.orbitFollowCenterHeight.velocityRef,
|
||||
values.orbitFollowCenterHeight.smoothing);
|
||||
|
||||
orbit.Orbits.Center.Radius = Mathf.SmoothDamp(orbit.Orbits.Center.Radius,
|
||||
values.orbitFollowCenterRadius.targetValue, ref values.orbitFollowCenterRadius.velocityRef,
|
||||
values.orbitFollowCenterRadius.smoothing);
|
||||
|
||||
orbit.Orbits.Bottom.Height = Mathf.SmoothDamp(orbit.Orbits.Bottom.Height,
|
||||
values.orbitFollowBottomHeight.targetValue, ref values.orbitFollowBottomHeight.velocityRef,
|
||||
values.orbitFollowBottomHeight.smoothing);
|
||||
|
||||
orbit.Orbits.Bottom.Radius = Mathf.SmoothDamp(orbit.Orbits.Bottom.Radius,
|
||||
values.orbitFollowBottomRadius.targetValue, ref values.orbitFollowBottomRadius.velocityRef,
|
||||
values.orbitFollowBottomRadius.smoothing);
|
||||
|
||||
rotComp.Composition.ScreenPosition = Vector2.SmoothDamp(rotComp.Composition.ScreenPosition,
|
||||
values.rotationComposerScreenPos.targetValue, ref values.rotationComposerScreenPos.velocityRefV2,
|
||||
values.rotationComposerScreenPos.smoothing);
|
||||
|
||||
offset.Offset = Vector3.SmoothDamp(offset.Offset,
|
||||
values.cameraOffsetOffset.targetValue, ref values.cameraOffsetOffset.velocityRefV3,
|
||||
values.cameraOffsetOffset.smoothing);
|
||||
|
||||
|
||||
// Initialize camera settings values from current values
|
||||
InitializeAllSettings();
|
||||
}
|
||||
|
||||
void Update(){
|
||||
ProcessCameraValues();
|
||||
SmoothCameraSettings();
|
||||
ApplyCameraSettings();
|
||||
}
|
||||
|
||||
void SmoothCameraSettings(){
|
||||
var settings = data.GetAllSettings();
|
||||
|
||||
for (int i = 0; i < settings.Count; i++) {
|
||||
settings[i].SmoothAndEase();
|
||||
}
|
||||
}
|
||||
|
||||
// Responsible for actively applying the settings to the Cinemachine components
|
||||
void ApplyCameraSettings(){
|
||||
main.Lens.FieldOfView = data.mainFieldOfView.Value;
|
||||
|
||||
axisCont.Controllers[0].Enabled = data.axisLookEnabledX.Value;
|
||||
axisCont.Controllers[1].Enabled = data.axisLookEnabledY.Value;
|
||||
|
||||
axisCont.Controllers[0].Input.Gain = data.axisLookGainX.Value;
|
||||
axisCont.Controllers[1].Input.Gain = data.axisLookGainY.Value;
|
||||
|
||||
orbit.TrackerSettings.PositionDamping = data.orbitPositionDamping.Value;
|
||||
orbit.TargetOffset = data.orbitTargetOffset.Value;
|
||||
|
||||
orbit.Orbits.Top.Height = data.orbitFollowTopHeight.Value;
|
||||
orbit.Orbits.Top.Radius = data.orbitFollowTopRadius.Value;
|
||||
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;
|
||||
|
||||
rotComp.Composition.ScreenPosition = data.rotationComposerScreenPos.Value;
|
||||
|
||||
offset.Offset = data.cameraOffsetOffset.Value;
|
||||
}
|
||||
|
||||
[Button]
|
||||
void InitializeAllSettings(){
|
||||
data.mainFieldOfView.targetValue = main.Lens.FieldOfView;
|
||||
|
||||
data.orbitPositionDamping.targetValue = orbit.TrackerSettings.PositionDamping;
|
||||
data.orbitTargetOffset.targetValue = orbit.TargetOffset;
|
||||
|
||||
data.axisLookEnabledX.targetValue = axisCont.Controllers[0].Enabled;
|
||||
data.axisLookEnabledY.targetValue = axisCont.Controllers[1].Enabled;
|
||||
|
||||
data.axisLookGainX.targetValue = axisCont.Controllers[0].Input.Gain;
|
||||
data.axisLookGainY.targetValue = axisCont.Controllers[1].Input.Gain;
|
||||
|
||||
data.orbitFollowTopHeight.targetValue = orbit.Orbits.Top.Height;
|
||||
data.orbitFollowTopRadius.targetValue = orbit.Orbits.Top.Radius;
|
||||
data.orbitFollowCenterHeight.targetValue = orbit.Orbits.Center.Height;
|
||||
data.orbitFollowCenterRadius.targetValue = orbit.Orbits.Center.Radius;
|
||||
data.orbitFollowBottomHeight.targetValue = orbit.Orbits.Bottom.Height;
|
||||
data.orbitFollowBottomRadius.targetValue = orbit.Orbits.Bottom.Radius;
|
||||
|
||||
data.rotationComposerScreenPos.targetValue = rotComp.Composition.ScreenPosition;
|
||||
data.cameraOffsetOffset.targetValue = offset.Offset;
|
||||
|
||||
var allSettings = data.GetAllSettings();
|
||||
for (int i = 0; i < allSettings.Count; i++) {
|
||||
allSettings[i].Initialize();
|
||||
allSettings[i].Verify();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
MatchInput,
|
||||
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
|
||||
56
Assets/Scripts/Player/ResolvedMovement.cs
Normal file
56
Assets/Scripts/Player/ResolvedMovement.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using Reset.Core.Tools;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Reset.Units{
|
||||
public class ResolvedMovement{
|
||||
public struct MoveDirection{
|
||||
private Transform owner;
|
||||
|
||||
// Both are in world space, and translated to local
|
||||
private Vector2 _moveRaw;
|
||||
private Vector2 _moveDir;
|
||||
|
||||
[ShowInInspector]
|
||||
public Vector2 World{
|
||||
get{
|
||||
DebugOverlayDrawer.ChangeValue("Movement", "_moveDir", _moveDir);
|
||||
return _moveDir;
|
||||
}
|
||||
set{
|
||||
_moveDir = value;
|
||||
}
|
||||
}
|
||||
|
||||
[ShowInInspector]
|
||||
public Vector2 Local => owner.InverseTransformDirection(_moveDir.ToVector3()).ToVector2();
|
||||
|
||||
[ShowInInspector, PropertySpace(5)]
|
||||
public Vector2 RawWorld{
|
||||
get{
|
||||
DebugOverlayDrawer.ChangeValue("Movement", "_moveRaw", _moveRaw);
|
||||
// return owner.TransformDirection(_moveDir.ToVector3()).ToVector2();
|
||||
return _moveRaw;
|
||||
}
|
||||
set{
|
||||
_moveRaw = value;
|
||||
}
|
||||
}
|
||||
|
||||
[ShowInInspector]
|
||||
public Vector2 RawLocal => owner.InverseTransformDirection(_moveRaw.ToVector3()).ToVector2();
|
||||
|
||||
public MoveDirection(Transform ownerTransform){
|
||||
owner = ownerTransform;
|
||||
_moveDir = Vector2.zero;
|
||||
_moveRaw = Vector2.zero;
|
||||
}
|
||||
}
|
||||
|
||||
[ShowInInspector, InlineProperty, BoxGroup("Direction"), HideLabel] 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
|
||||
107
Assets/Scripts/Player/SettingValue.cs
Normal file
107
Assets/Scripts/Player/SettingValue.cs
Normal file
@@ -0,0 +1,107 @@
|
||||
using System;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
public interface IResettableSettingValue{
|
||||
public void Verify();
|
||||
public void SmoothAndEase();
|
||||
public void Initialize();
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class SettingValue<T> : IResettableSettingValue{
|
||||
[HorizontalGroup("Settings", width: .3f), VerticalGroup("Settings/Value"), BoxGroup("Settings/Value/Value"), LabelText("Target")]
|
||||
public T targetValue;
|
||||
[HorizontalGroup("Settings"), VerticalGroup("Settings/Value"), BoxGroup("Settings/Value/Value"), LabelText("Current")]
|
||||
public T currentValue;
|
||||
[HorizontalGroup("Settings"), VerticalGroup("Settings/Smoothing"), BoxGroup("Settings/Smoothing/Smoothing"), LabelText("Target"), ShowIf("@IsSmoothable()")]
|
||||
public float targetSmoothing; // Smoothing changes how fast the value is changed.
|
||||
[HorizontalGroup("Settings"), VerticalGroup("Settings/Easing"), BoxGroup("Settings/Easing/Easing"), LabelText("Target"), ShowIf("@IsSmoothable()")]
|
||||
public float targetEasing; // Easing changes how fast smoothing is changed, when given a new value.
|
||||
|
||||
public T Value{
|
||||
get => currentValue;
|
||||
set => targetValue = value;
|
||||
}
|
||||
[HorizontalGroup("Settings"), VerticalGroup("Settings/Smoothing"), BoxGroup("Settings/Smoothing/Smoothing"), LabelText("Current"), ShowIf("@IsSmoothable()")]
|
||||
public float currentSmoothing;
|
||||
[HorizontalGroup("Settings"), VerticalGroup("Settings/Value"), BoxGroup("Settings/Value/Value"), LabelText("Default")]
|
||||
public T defaultValue;
|
||||
[HorizontalGroup("Settings"), VerticalGroup("Settings/Smoothing"), BoxGroup("Settings/Smoothing/Smoothing"), LabelText("Default"), ShowIf("@IsSmoothable()")]
|
||||
public float defaultSmoothing;
|
||||
[HorizontalGroup("Settings"), VerticalGroup("Settings/Easing"), BoxGroup("Settings/Easing/Easing"), LabelText("Default"), ShowIf("@IsSmoothable()")]
|
||||
public float defaultEasing;
|
||||
|
||||
private float refVelFloat; // For use with SmoothDamp
|
||||
private Vector3 refVelV3; // For use with SmoothDamp
|
||||
private Vector2 refVelV2; // For use with SmoothDamp
|
||||
|
||||
private bool verified;
|
||||
|
||||
bool IsSmoothable(){
|
||||
return (typeof(T) == typeof(float) || typeof(T) == typeof(Vector2) || typeof(T) == typeof(Vector3) || typeof(T) == typeof(Vector4) || typeof(T) == typeof(Quaternion) );
|
||||
}
|
||||
|
||||
public SettingValue(T initValue, float defaultEasing = 2f, float defaultSmoothing = 1f){
|
||||
targetValue = initValue;
|
||||
|
||||
defaultValue = initValue;
|
||||
|
||||
this.defaultSmoothing = defaultSmoothing;
|
||||
this.defaultEasing = defaultEasing;
|
||||
|
||||
targetEasing = defaultEasing;
|
||||
targetSmoothing = defaultSmoothing;
|
||||
|
||||
currentSmoothing = targetSmoothing;
|
||||
currentValue = targetValue;
|
||||
|
||||
refVelFloat = 0;
|
||||
refVelV3 = default;
|
||||
refVelV2 = default;
|
||||
}
|
||||
|
||||
public void Verify(){
|
||||
if (targetValue.Equals(currentValue) == false) {
|
||||
Debug.LogWarning($"A SettingValue ({this}) doesn't have its current and target value matching. This should have been set!");
|
||||
}
|
||||
|
||||
verified = true;
|
||||
}
|
||||
|
||||
public void SmoothAndEase(){
|
||||
if (!verified) {
|
||||
Debug.LogWarning($"A SettingValue ({this}) wasn't verified before being smoothed and eased. What's up with that?");
|
||||
}
|
||||
|
||||
currentSmoothing = Mathf.MoveTowards(currentSmoothing, targetSmoothing, targetEasing * targetEasing * Time.deltaTime);
|
||||
|
||||
if (typeof(T) == typeof(float)) {
|
||||
currentValue = (T)(object)Mathf.SmoothDamp((float)(object)currentValue, (float)(object)targetValue, ref refVelFloat, currentSmoothing * currentSmoothing * Time.deltaTime);
|
||||
}
|
||||
|
||||
if (typeof(T) == typeof(Vector2)) {
|
||||
currentValue = (T)(object)Vector2.SmoothDamp((Vector2)(object)currentValue, (Vector2)(object)targetValue, ref refVelV2, currentSmoothing * currentSmoothing * Time.deltaTime);
|
||||
}
|
||||
|
||||
if (typeof(T) == typeof(Vector3)) {
|
||||
currentValue = (T)(object)Vector3.SmoothDamp((Vector3)(object)currentValue, (Vector3)(object)targetValue, ref refVelV3, currentSmoothing * 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 * currentSmoothing * Time.deltaTime);
|
||||
float v4value = Mathf.SmoothDamp(((Vector4)(object)currentValue).z, ((Vector4)(object)targetValue).z, ref refVelFloat, currentSmoothing * currentSmoothing * Time.deltaTime);
|
||||
|
||||
currentValue = (T)(object)new Vector4(v3value.x, v3value.y, v3value.z, v4value);
|
||||
}
|
||||
}
|
||||
|
||||
public void Initialize(){
|
||||
currentValue = targetValue;
|
||||
defaultValue = targetValue;
|
||||
defaultSmoothing = targetSmoothing;
|
||||
defaultEasing = targetEasing;
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Player/SettingValue.cs.meta
Normal file
3
Assets/Scripts/Player/SettingValue.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 03e2aa4743404e9fbf8b14033c5eda7b
|
||||
timeCreated: 1758126336
|
||||
62
Assets/Scripts/Player/UnitMovementData.cs
Normal file
62
Assets/Scripts/Player/UnitMovementData.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ParadoxNotion.Design;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Reset.Units{
|
||||
[Serializable]
|
||||
public class UnitMovementData{
|
||||
// Movement Direction
|
||||
[Title("Direction Changing Softeness"), HideLabel, InlineProperty] public SettingValue<float> directionChangingSoftness = new SettingValue<float>(1f, defaultSmoothing: 1f);
|
||||
[Title("Direction Spinning Hardness"), HideLabel, InlineProperty] public SettingValue<float> directionSpinningHardness = new SettingValue<float>(3f, defaultSmoothing: 1f);
|
||||
[Title("Directoon Spinning Speed"), HideLabel, InlineProperty] public SettingValue<float> directionSpinningSpeed= new SettingValue<float>(3f, defaultSmoothing: 1f);
|
||||
|
||||
[SliderField(0,1)]
|
||||
[Title("Air Direction Decay"), HideLabel, InlineProperty] public SettingValue<float> airDirectionDecay = new SettingValue<float>(1f); // TODO: Check default value
|
||||
|
||||
// Move Speed
|
||||
[Title("Acceleration"), HideLabel, InlineProperty] public SettingValue<float> acceleration = new SettingValue<float>(5f);
|
||||
[Title("Deacceleration"), HideLabel, InlineProperty] public SettingValue<float> deacceleration = new SettingValue<float>(5f);
|
||||
[Title("Move Speed"), HideLabel, InlineProperty] public SettingValue<float> moveSpeed = new SettingValue<float>(15f, defaultSmoothing: 10f);
|
||||
|
||||
// Jumping
|
||||
// [Title("Jump Power"), HideLabel, InlineProperty] [ShowInInspector] public SettingValue<float> jumpPower = new SettingValue<float>(0f);
|
||||
// [Title("Move Smoothing"), HideLabel, InlineProperty] public SettingValue<float> jumpPowerDecay = new SettingValue<float>(3f); // TODO: Check default value
|
||||
|
||||
// Gravity
|
||||
[Title("Gravity Power"), HideLabel, InlineProperty] [ShowInInspector] public SettingValue<float> gravityPower = new SettingValue<float>(1f);
|
||||
[Title("Gravity Max"), HideLabel, InlineProperty] public SettingValue<float> gravityMax = new SettingValue<float>(8f);
|
||||
[Title("Gravity Acceleration"), HideLabel, InlineProperty] public SettingValue<float> gravityAcceleration = new SettingValue<float>(1f);
|
||||
[Title("Gravity Scale"), HideLabel, InlineProperty] public SettingValue<float> gravityScale = new SettingValue<float>(1f);
|
||||
|
||||
// Rotation
|
||||
[Title("Rotate Facing"), HideLabel, InlineProperty] public SettingValue<PlayerFacingDirection> facingDirection = new SettingValue<PlayerFacingDirection>(initValue: PlayerFacingDirection.Momentum);
|
||||
[Title("Rotation Speed"), HideLabel, InlineProperty] public SettingValue<float> rotationSpeed = new SettingValue<float>(5f);
|
||||
|
||||
|
||||
public List<IResettableSettingValue> GetAllSettings(){
|
||||
var outputList = new List<IResettableSettingValue>();
|
||||
|
||||
IResettableSettingValue[] settings = {
|
||||
directionChangingSoftness,
|
||||
directionSpinningHardness,
|
||||
directionSpinningSpeed,
|
||||
acceleration,
|
||||
deacceleration,
|
||||
airDirectionDecay,
|
||||
moveSpeed,
|
||||
gravityPower,
|
||||
gravityMax,
|
||||
gravityAcceleration,
|
||||
gravityScale,
|
||||
facingDirection,
|
||||
rotationSpeed,
|
||||
};
|
||||
|
||||
outputList.AddRange(settings);
|
||||
|
||||
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,243 +1,133 @@
|
||||
using System;
|
||||
using NUnit.Framework.Internal;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using ParadoxNotion.Design;
|
||||
using Reset.Core.Tools;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine.Serialization;
|
||||
using Quaternion = UnityEngine.Quaternion;
|
||||
|
||||
public enum PlayerFacingDirection{
|
||||
TowardsTarget = 0,
|
||||
MatchForward,
|
||||
MatchCamera,
|
||||
Static,
|
||||
Momentum,
|
||||
SpecifiedDirection
|
||||
}
|
||||
|
||||
namespace Reset.Units{
|
||||
// public interface IBuffSource{ - Unused good idea?
|
||||
// public Object sourceObject();
|
||||
// public
|
||||
// }
|
||||
|
||||
[Serializable]
|
||||
public class UnitMovementData : ICloneable{
|
||||
// Movement Direction
|
||||
public float accelerationSmoothing = 5f;
|
||||
public float deaccelerationSmoothing = 5f;
|
||||
// public AnimationCurve deaccelerationCurve; // Currently unused, may return
|
||||
|
||||
[SliderField(0,1)]
|
||||
public float airDirectionDecay;
|
||||
|
||||
// Move Speed
|
||||
public float moveSpeed = 15f;
|
||||
public float moveSpeedSoothing = 10f;
|
||||
|
||||
// Jumping
|
||||
[ShowInInspector, ReadOnly] public float jumpPower;
|
||||
public float jumpPowerDecay = 3f;
|
||||
|
||||
// Gravity
|
||||
[ShowInInspector, ReadOnly] public float gravityPower;
|
||||
public float gravityMax = 8f;
|
||||
public float gravityAcceleration = 1f;
|
||||
public float gravityScale = 1f;
|
||||
public float settingsChangeSmoothing = 6f;
|
||||
|
||||
// Rotation
|
||||
[ShowInInspector, SerializeReference]
|
||||
public Enum rotateFacing;
|
||||
[FormerlySerializedAs("rotationSpeedTarget")] public float rotationSpeed = 5f;
|
||||
public float rotationSmoothing = 1f;
|
||||
public float rotationInputBlending = .3f;
|
||||
|
||||
public object Clone(){
|
||||
return MemberwiseClone();
|
||||
}
|
||||
}
|
||||
|
||||
public class UnitMovementHandler : MonoBehaviour{
|
||||
// class MovementFloatModifier{
|
||||
// // IBuffSource source
|
||||
// public float value;
|
||||
// }
|
||||
[ShowInInspector, InlineProperty, HideLabel, FoldoutGroup("Resolved Movement", expanded: true)]
|
||||
public ResolvedMovement resolvedMovement;
|
||||
|
||||
//
|
||||
[FoldoutGroup("Final Values"), ShowInInspector, ReadOnly] private float outputSpeed;
|
||||
[FoldoutGroup("Final Values"), ShowInInspector, ReadOnly] private float additionalSpeed;
|
||||
[FoldoutGroup("Final Values"), ShowInInspector, ReadOnly] public Vector3 outputMoveDirection;
|
||||
[FoldoutGroup("Final Values"), ShowInInspector, ReadOnly] public Vector3 additionalMoveDirection;
|
||||
[FoldoutGroup("Final Values"), ShowInInspector, ReadOnly] private Quaternion outputRotation;
|
||||
[FoldoutGroup("Final Values"), ShowInInspector, ReadOnly] private Quaternion specifiedRotation;
|
||||
[FoldoutGroup("Final Values"), ShowInInspector, ReadOnly] private float outputRotationSpeed;
|
||||
// SmoothDamp Velocities
|
||||
private Vector2 refVelocityDirectionChangingHardness;
|
||||
|
||||
// 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
|
||||
[FoldoutGroup("Smoothed Values"), ShowInInspector, ReadOnly] private float smoothedJumpDecay;
|
||||
[FoldoutGroup("Smoothed Values"), ShowInInspector, ReadOnly] private float smoothedGravityAccel;
|
||||
[FoldoutGroup("Smoothed Values"), ShowInInspector, ReadOnly] private float smoothedGravityScale;
|
||||
[FoldoutGroup("Smoothed Values"), ShowInInspector, ReadOnly] private float settingsChangeRotationSpeed;
|
||||
|
||||
private float directionChangeDot;
|
||||
private bool moveCallDisabledNextFrame;
|
||||
|
||||
private bool movedThisFrame;
|
||||
// Smoothing Values
|
||||
private float directionChangeDotLerp;
|
||||
private Vector3 moveSmoothVelocityRef;
|
||||
private float gravitySmoothVelocityRef;
|
||||
|
||||
// References
|
||||
private CharacterController controller;
|
||||
private PlayerControls controls;
|
||||
private LockOnManager lockOnManager;
|
||||
|
||||
private Vector3 moveSmooth;
|
||||
public float gravitySmooth;
|
||||
// Movement Data
|
||||
[ShowInInspector, PropertyOrder(2), FoldoutGroup("Movement Data", expanded: true), InlineProperty, HideLabel] public UnitMovementData data = new();
|
||||
|
||||
private bool relativeToCamera;
|
||||
|
||||
[ShowInInspector, PropertyOrder(2)]
|
||||
public UnitMovementData data = new();
|
||||
|
||||
[HideInInspector]
|
||||
public UnitMovementData defaultData;
|
||||
// Other
|
||||
private Quaternion specifiedRotation; // Used for locking a specific direction
|
||||
|
||||
void Awake(){
|
||||
controller = GetComponent<CharacterController>();
|
||||
controls = GetComponent<PlayerControls>();
|
||||
lockOnManager = GetComponent<LockOnManager>();
|
||||
|
||||
InitAllSettings();
|
||||
}
|
||||
|
||||
private void Start(){
|
||||
defaultData = (UnitMovementData)data.Clone();
|
||||
void Start(){
|
||||
resolvedMovement = new ResolvedMovement{
|
||||
moveDirection = new ResolvedMovement.MoveDirection(transform)
|
||||
};
|
||||
}
|
||||
|
||||
void Update(){
|
||||
SmoothAllSettings();
|
||||
|
||||
UpdateCurrentDirection();
|
||||
UpdateCurrentGravity();
|
||||
UpdateCurrentSpeed();
|
||||
|
||||
UpdateCurrentRotation();
|
||||
|
||||
DoMovement();
|
||||
}
|
||||
// Apply movement
|
||||
DoMovement(resolvedMovement.moveDirection.World, resolvedMovement.gravity, resolvedMovement.moveSpeed, data.gravityScale.Value);
|
||||
|
||||
// Add directly to the direction
|
||||
public void AddToCurrentDirection(Vector3 inputDirection, float power){
|
||||
additionalMoveDirection += inputDirection.normalized;
|
||||
additionalSpeed = power;
|
||||
}
|
||||
|
||||
public void SmoothToSpeed(float desiredSpeed, float smoothing){
|
||||
additionalSpeed = Mathf.Lerp(additionalSpeed, desiredSpeed, smoothing * Time.deltaTime);
|
||||
}
|
||||
|
||||
public void SetNewDirection(Vector3 inputDirection){ // NOTE: If smoothing desired add a default bool for smoothing maybe?
|
||||
additionalMoveDirection = inputDirection.Flatten(null, 0f, null);
|
||||
}
|
||||
|
||||
public void SetNewGravity(float value){
|
||||
additionalMoveDirection.y = value;
|
||||
}
|
||||
|
||||
// Hold a new rotation to be moved to during PlayerFacingDirection.SpecifiedRotation
|
||||
public void SetSpecifiedRotation(Quaternion inputRotation){
|
||||
specifiedRotation = inputRotation;
|
||||
}
|
||||
|
||||
// Blend between the current direction and an input direction, based on the current controller input
|
||||
public void OverwriteDirectionFromInput(Vector2 value, float priority, float speed = Mathf.Infinity){
|
||||
// Create a new direction that is the current controller input * the amount of power they should have
|
||||
Vector3 dirToAdd = new Vector3(controls.rawMoveInput.x * value.x, 0f, controls.rawMoveInput.y * value.y);
|
||||
|
||||
// Multiply it by the current magnitude (why? i forgor)
|
||||
dirToAdd *= controls.rawMoveInput.magnitude;
|
||||
|
||||
// Blend the existing direction into it
|
||||
dirToAdd = Vector3.Lerp(outputMoveDirection, dirToAdd, priority * controls.rawMoveInput.magnitude);
|
||||
|
||||
// Set the new direction
|
||||
outputMoveDirection = new Vector3(dirToAdd.x, outputMoveDirection.y, dirToAdd.z);
|
||||
|
||||
// Everthing under here is for the speed now. If it's not set do...nothing. Otherwise set it to the max value between move speed and the new speed
|
||||
if (float.IsPositiveInfinity(speed)) {
|
||||
return;
|
||||
}
|
||||
|
||||
outputSpeed = Mathf.Lerp(outputSpeed, Mathf.Max(data.moveSpeed, speed), priority);
|
||||
DebugOverlayDrawer.ChangeValue("Movement", "Move Direction (Local)", resolvedMovement.moveDirection.Local);
|
||||
DebugOverlayDrawer.ChangeValue("Movement", "Move Direction (World)", resolvedMovement.moveDirection.World);
|
||||
}
|
||||
|
||||
// Update the direction, called every frame
|
||||
private void UpdateCurrentDirection(){
|
||||
// Get input value
|
||||
Vector3 inputMovement = new Vector3(controls.rawMoveInput.x, 0f, controls.rawMoveInput.y);
|
||||
Vector2 targetDirection = new Vector2(controls.rawMoveInput.x, controls.rawMoveInput.y);
|
||||
|
||||
// Construct move direction
|
||||
Vector3 targetDirection = inputMovement;
|
||||
// Rotate input by camera rotation (instead of rotating the output direction by camera rotation)
|
||||
targetDirection = (Camera.main.transform.rotation * targetDirection.ToVector3()).ToVector2();
|
||||
|
||||
// Deadzone
|
||||
if (inputMovement.magnitude < .05f) {
|
||||
targetDirection = Vector3.zero;
|
||||
if (targetDirection.magnitude < .08f) {
|
||||
targetDirection = Vector2.zero;
|
||||
}
|
||||
|
||||
// Remove Y from variables
|
||||
Vector3 targetNoY = new Vector3(targetDirection.x, 0f, targetDirection.z);
|
||||
Vector3 currentNoY = new Vector3(outputMoveDirection.x, 0f, outputMoveDirection.z);
|
||||
// Set Raw Direction (this is used by the camera later)
|
||||
resolvedMovement.moveDirection.RawWorld = targetDirection;
|
||||
|
||||
// Get current direction
|
||||
Vector2 currentDirection = resolvedMovement.moveDirection.World;
|
||||
|
||||
// Also need to find the dot value of the current input versus the current move direction
|
||||
Vector3 slerpedValue;
|
||||
Vector3 lerpedValue;
|
||||
|
||||
float switchedDirection = Vector3.Dot(inputMovement, outputMoveDirection);
|
||||
float switchedDirection = Vector3.Dot(targetDirection, currentDirection);
|
||||
float switchedDirectionRemapped = Mathf.Lerp(0, 1, switchedDirection);
|
||||
|
||||
directionChangeDot = Mathf.Lerp(switchedDirection, switchedDirectionRemapped, 5f * Time.deltaTime) ; // turn that .5f into a variable
|
||||
directionChangeDotLerp = Mathf.Lerp(switchedDirection, switchedDirectionRemapped, data.directionSpinningHardness.Value * Time.deltaTime);
|
||||
DebugOverlayDrawer.ChangeValue("Movement", "Direction Change Dot", directionChangeDotLerp);
|
||||
|
||||
// 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
|
||||
if (targetNoY.magnitude > currentNoY.magnitude) {
|
||||
Vector3 slerpedValue;
|
||||
Vector2 lerpedValue;
|
||||
Vector2 newDirection;
|
||||
|
||||
if (controller.isGrounded){
|
||||
slerpedValue = Vector3.Slerp(currentNoY, targetNoY, data.accelerationSmoothing * Time.deltaTime);
|
||||
lerpedValue = Vector3.Lerp(currentNoY, targetNoY, data.accelerationSmoothing * Time.deltaTime);
|
||||
slerpedValue = Vector3.Slerp(currentDirection, targetDirection, data.directionSpinningSpeed.Value * Time.deltaTime);
|
||||
lerpedValue = Vector2.SmoothDamp(currentDirection, targetDirection, ref refVelocityDirectionChangingHardness, data.directionChangingSoftness.Value * Time.deltaTime);
|
||||
|
||||
currentNoY = Vector3.Lerp(lerpedValue, slerpedValue, directionChangeDot);
|
||||
newDirection = Vector2.Lerp(slerpedValue, lerpedValue, directionChangeDotLerp);
|
||||
} else {
|
||||
currentNoY = Vector3.Lerp(currentNoY, targetNoY, data.accelerationSmoothing * Time.deltaTime);
|
||||
}
|
||||
} else {
|
||||
if (controller.isGrounded){
|
||||
slerpedValue = Vector3.Slerp(currentNoY, targetNoY, data.deaccelerationSmoothing * Time.deltaTime);
|
||||
lerpedValue = Vector3.Lerp(currentNoY, targetNoY, data.deaccelerationSmoothing * Time.deltaTime);
|
||||
|
||||
currentNoY = Vector3.Lerp(lerpedValue, slerpedValue, directionChangeDot);
|
||||
} else {
|
||||
currentNoY = Vector3.Lerp(currentNoY, targetNoY, data.deaccelerationSmoothing * data.airDirectionDecay * Time.deltaTime);
|
||||
}
|
||||
newDirection = Vector2.SmoothDamp(currentDirection, targetDirection, ref refVelocityDirectionChangingHardness, data.directionChangingSoftness.Value * data.airDirectionDecay.Value * Time.deltaTime);
|
||||
}
|
||||
|
||||
// Commit move direction
|
||||
outputMoveDirection = Vector3.SmoothDamp(outputMoveDirection, new Vector3(currentNoY.x, outputMoveDirection.y, currentNoY.z),ref moveSmooth , .5f *Time.deltaTime);
|
||||
// Commit the new direction
|
||||
resolvedMovement.moveDirection.World = newDirection;
|
||||
}
|
||||
|
||||
// Update the speed, called every frame
|
||||
private void UpdateCurrentSpeed(){
|
||||
Debug.Log(data.moveSpeed);
|
||||
outputSpeed = Mathf.Lerp(outputSpeed, data.moveSpeed, data.moveSpeedSoothing * Time.deltaTime);
|
||||
// ""Smooth"" the speed
|
||||
float smoothedSpeed;
|
||||
|
||||
if (resolvedMovement.moveDirection.Local.magnitude < controls.rawMoveInput.magnitude) {
|
||||
smoothedSpeed = Mathf.MoveTowards(resolvedMovement.moveSpeed, data.moveSpeed.Value, data.acceleration.Value * Time.deltaTime);
|
||||
} else {
|
||||
smoothedSpeed = Mathf.MoveTowards(resolvedMovement.moveSpeed, 0f, data.deacceleration.Value * Time.deltaTime);
|
||||
}
|
||||
|
||||
// Commit the speed
|
||||
resolvedMovement.moveSpeed = smoothedSpeed;
|
||||
|
||||
DebugOverlayDrawer.ChangeValue("Movement", "Resolved Speed", resolvedMovement.moveSpeed);
|
||||
}
|
||||
|
||||
// Update the gravity, called every frame
|
||||
// NOTE: most gravity interactions, like when grounded or not, is now handled by the state machine
|
||||
private void UpdateCurrentGravity(){
|
||||
// Accelerate gravity
|
||||
data.gravityPower += smoothedGravityAccel * Time.deltaTime;
|
||||
data.gravityPower = Mathf.Clamp(data.gravityPower, Mathf.NegativeInfinity, data.gravityMax);
|
||||
|
||||
// Apply a constant gravity if the player is grounded
|
||||
if (controller.isGrounded) {
|
||||
data.gravityPower = .1f;
|
||||
if (!controller.isGrounded){
|
||||
resolvedMovement.gravity -= data.gravityAcceleration.Value * Time.deltaTime;
|
||||
}
|
||||
|
||||
// Create the final gravity value
|
||||
float gravityMoveDirection = data.jumpPower + (Physics.gravity.y * data.gravityPower);
|
||||
|
||||
// Commit gravity to move direction, ignoring XZ since those are done in UpdateMovementDirection
|
||||
outputMoveDirection.y = Mathf.SmoothDamp(outputMoveDirection.y, gravityMoveDirection, ref gravitySmooth, .1f * Time.deltaTime);
|
||||
float gravityMoveDirection = Physics.gravity.y * resolvedMovement.gravity;
|
||||
}
|
||||
|
||||
// Update the rotation, called every frame
|
||||
@@ -245,122 +135,161 @@ namespace Reset.Units{
|
||||
// Get input value
|
||||
Vector3 inputMovement = new Vector3(controls.rawMoveInput.x, 0f, controls.rawMoveInput.y);
|
||||
|
||||
Quaternion targetRotation = Quaternion.identity;
|
||||
// Switch the desired rotation based on current movement setting
|
||||
switch (data.rotateFacing) {
|
||||
switch (data.facingDirection.Value) {
|
||||
// Just look at target
|
||||
case PlayerFacingDirection.TowardsTarget:
|
||||
// Look directly at the target
|
||||
outputRotation = Quaternion.LookRotation(transform.position.DirectionTo(lockOnManager.mainTarget.gameObject.transform.position));
|
||||
if (lockOnManager.mainTarget == null) {
|
||||
Debug.LogError("Trying to rotate towards a target but there is no target. Not setting a rotation");
|
||||
targetRotation = transform.rotation;
|
||||
break;
|
||||
}
|
||||
|
||||
targetRotation = Quaternion.LookRotation(transform.position.DirectionTo(lockOnManager.mainTarget.gameObject.transform.position));
|
||||
break;
|
||||
case PlayerFacingDirection.Momentum:
|
||||
// Look towards the current direction the agent is moving
|
||||
if (inputMovement.magnitude > .05f){
|
||||
outputRotation = Camera.main.transform.rotation * Quaternion.LookRotation(outputMoveDirection);
|
||||
targetRotation = Quaternion.LookRotation(resolvedMovement.moveDirection.RawWorld.ToVector3(), Vector3.up);
|
||||
}
|
||||
break;
|
||||
case PlayerFacingDirection.MatchForward:
|
||||
// Look towards the input direction....why??? I guess cause move direction is PlayerFacingDirection.Momentum.
|
||||
case PlayerFacingDirection.MatchInput:
|
||||
// Look towards the input direction- similar to Momentum but snappier
|
||||
if (controls.rawMoveInput.magnitude < 0.05f) { break; }
|
||||
|
||||
outputRotation = Camera.main.transform.rotation * Quaternion.LookRotation(inputMovement);
|
||||
targetRotation = Camera.main.transform.rotation * Quaternion.LookRotation(inputMovement);
|
||||
break;
|
||||
case PlayerFacingDirection.MatchCamera:
|
||||
// Look the same direction as the camera
|
||||
outputRotation = Quaternion.Euler(Camera.main.transform.rotation.eulerAngles.Flatten(0, null, 0));
|
||||
targetRotation = Quaternion.Euler(Camera.main.transform.rotation.eulerAngles.Flatten(0, null, 0));
|
||||
break;
|
||||
case PlayerFacingDirection.Static:
|
||||
// Don't change
|
||||
outputRotation = transform.rotation;
|
||||
break;
|
||||
case PlayerFacingDirection.SpecifiedDirection:
|
||||
// Look at an inputed rotation
|
||||
outputRotation = specifiedRotation;
|
||||
targetRotation = resolvedMovement.rotation;
|
||||
break;
|
||||
}
|
||||
|
||||
DebugOverlayDrawer.ChangeValue("Rotation", "Target Rotation", targetRotation.eulerAngles);
|
||||
|
||||
// Add the current input into the created rotation
|
||||
if (inputMovement.magnitude > .05) {
|
||||
outputRotation = Quaternion.Lerp(outputRotation, Camera.main.transform.rotation * Quaternion.LookRotation(inputMovement), data.rotationInputBlending);
|
||||
resolvedMovement.rotation = targetRotation;
|
||||
} else if (data.facingDirection.Value == PlayerFacingDirection.MatchCamera) {
|
||||
resolvedMovement.rotation = targetRotation;
|
||||
}
|
||||
|
||||
// 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, settingsChangeRotationSpeed * Time.deltaTime);
|
||||
|
||||
// Set final rotation
|
||||
transform.rotation = Quaternion.Slerp(transform.rotation, outputRotation, outputRotationSpeed * Time.deltaTime).Flatten(0, null, 0);
|
||||
// Apply rotation to the character
|
||||
transform.rotation = Quaternion.Slerp(transform.rotation, resolvedMovement.rotation, data.rotationSpeed.Value * Time.deltaTime).Flatten(0, null, 0);
|
||||
}
|
||||
|
||||
// Move with default settings
|
||||
public void DoMovement(){
|
||||
DoMovement(outputMoveDirection, outputSpeed, data.gravityScale);
|
||||
}
|
||||
|
||||
public void DisableNextMoveCall(){
|
||||
moveCallDisabledNextFrame = true;
|
||||
}
|
||||
|
||||
// Custom move from input
|
||||
public void DoMovement(Vector3 moveDir, float speed, float gravityScale){
|
||||
// Debug.Log($"moveDir: {moveDir}, agent velocity: {transform.InverseTransformDirection(controller.velocity.normalized)}");
|
||||
|
||||
private void DoMovement(Vector2 moveDir, float gravDir, float speed, float gravityScale){
|
||||
// Seperate the different move directions. Additonal becomes it's own because it needs to be added independently of the other two
|
||||
Vector3 moveXZDir = new Vector3(moveDir.x, 0f, moveDir.z);
|
||||
Vector3 moveYDir = new Vector3(0f, moveDir.y, 0f);
|
||||
Vector3 addDir = additionalMoveDirection;
|
||||
Vector2 moveXZDir = moveDir;
|
||||
float moveYDir = gravDir;
|
||||
|
||||
// Add their related speeds
|
||||
moveXZDir *= speed * Time.deltaTime;
|
||||
moveYDir *= smoothedGravityScale * Time.deltaTime;
|
||||
addDir *= additionalSpeed * Time.deltaTime;
|
||||
moveYDir *= data.gravityScale.Value * Time.deltaTime;
|
||||
|
||||
// Construct the direction and move
|
||||
Vector3 finalDir = moveXZDir + moveYDir;
|
||||
controller.Move((Camera.main.transform.rotation.Flatten(0, null, 0) * finalDir) + addDir);
|
||||
Vector3 finalDir = new Vector3(moveXZDir.x, moveYDir, moveXZDir.y);
|
||||
controller.Move(finalDir);
|
||||
}
|
||||
|
||||
void LateUpdate(){
|
||||
UpdateGravityLate();
|
||||
DecayAdditionalDirection();
|
||||
SmoothingSettingsChanges();
|
||||
}
|
||||
|
||||
private void SmoothingSettingsChanges(){
|
||||
smoothedJumpDecay = Mathf.Lerp(smoothedJumpDecay, data.jumpPowerDecay, data.settingsChangeSmoothing * Time.deltaTime);
|
||||
smoothedGravityAccel = Mathf.Lerp(smoothedGravityAccel, data.gravityAcceleration, data.settingsChangeSmoothing * Time.deltaTime);
|
||||
smoothedGravityScale = Mathf.Lerp(smoothedGravityScale, data.gravityScale, data.settingsChangeSmoothing * Time.deltaTime);
|
||||
settingsChangeRotationSpeed = Mathf.Lerp(settingsChangeRotationSpeed, data.rotationSpeed, data.settingsChangeSmoothing * Time.deltaTime);
|
||||
}
|
||||
|
||||
void DecayAdditionalDirection(){
|
||||
// Get input value
|
||||
Vector3 inputMovement = new Vector3(controls.rawMoveInput.x, 0f, controls.rawMoveInput.y);
|
||||
|
||||
// Ignore values under deadzone
|
||||
if (inputMovement.magnitude < .1f) {
|
||||
inputMovement = Vector3.zero;
|
||||
}
|
||||
|
||||
// Remove Y from variables
|
||||
Vector3 currentNoY = new Vector3(additionalMoveDirection.x, 0f, additionalMoveDirection.z);
|
||||
|
||||
// Decay the direction
|
||||
if (inputMovement.magnitude < currentNoY.magnitude) {
|
||||
additionalMoveDirection = Vector3.Slerp(additionalMoveDirection, Vector3.zero,data.accelerationSmoothing * Time.deltaTime);
|
||||
// Setting absolute to true will cause the current gravity to snap to the new gravity value.
|
||||
// Keeping it false will make it apply additively to the current gravity. Both options use relativty for linear interpolation.
|
||||
public void SetNewGravity(float value, float relativity, bool absolute){ // new
|
||||
if (absolute){
|
||||
resolvedMovement.gravity = Mathf.Lerp(resolvedMovement.gravity, value, relativity);
|
||||
} else {
|
||||
// float deaccelValue = data.deaccelerationCurve.Evaluate(inputMovement.magnitude);
|
||||
additionalMoveDirection = Vector3.Lerp(additionalMoveDirection, Vector3.zero, data.deaccelerationSmoothing * Time.deltaTime);
|
||||
}
|
||||
|
||||
// Decay the gravity
|
||||
additionalMoveDirection.y -= data.gravityPower;
|
||||
additionalMoveDirection.y = Mathf.Max(0f, additionalMoveDirection.y);
|
||||
}
|
||||
|
||||
private void UpdateGravityLate(){
|
||||
// Decay jump power
|
||||
data.jumpPower -= smoothedJumpDecay * Time.deltaTime;
|
||||
data.jumpPower = Mathf.Max(0f, data.jumpPower);
|
||||
}
|
||||
resolvedMovement.gravity = Mathf.Lerp(resolvedMovement.gravity, resolvedMovement.gravity + value, relativity);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetNewDirection(Vector2 value, float relativity, bool absolute, Vector2 relativeTo = default){ // new
|
||||
Vector2 relativeValue = relativeTo + value;
|
||||
|
||||
if (absolute){
|
||||
resolvedMovement.moveDirection.World = Vector2.Lerp(resolvedMovement.moveDirection.World, relativeValue, relativity);
|
||||
} else {
|
||||
resolvedMovement.moveDirection.World = Vector2.Lerp(resolvedMovement.moveDirection.World, resolvedMovement.moveDirection.World + relativeValue, relativity);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetNewRawDirection(Vector2 value, float relativity, bool absolute, Vector2 relativeTo = default){ // new
|
||||
Vector2 relativeValue = relativeTo + value;
|
||||
|
||||
if (absolute){
|
||||
resolvedMovement.moveDirection.RawWorld = Vector2.Lerp(resolvedMovement.moveDirection.RawWorld, relativeValue, relativity);
|
||||
} else {
|
||||
resolvedMovement.moveDirection.RawWorld = Vector2.Lerp(resolvedMovement.moveDirection.RawWorld, resolvedMovement.moveDirection.RawWorld + relativeValue, relativity);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetNewSpeed(float value, float relativity, bool absolute, float relativeTo = Mathf.Infinity){ // new
|
||||
if (absolute){
|
||||
resolvedMovement.moveSpeed = Mathf.Lerp(resolvedMovement.moveSpeed, value, relativity);
|
||||
} else {
|
||||
resolvedMovement.moveSpeed = Mathf.Lerp(resolvedMovement.moveSpeed, resolvedMovement.moveSpeed + value, relativity);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetNewRotation(Quaternion value, float relativity, bool absolute, Quaternion relativeTo = default){ // new
|
||||
Quaternion relativeValue = relativeTo * value;
|
||||
|
||||
if (absolute){
|
||||
resolvedMovement.rotation = Quaternion.Lerp(resolvedMovement.rotation, relativeValue, relativity);
|
||||
} else {
|
||||
resolvedMovement.rotation = Quaternion.Lerp(resolvedMovement.rotation, resolvedMovement.rotation * relativeValue, relativity);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetSpecifiedRotation(Quaternion inputRotation){
|
||||
specifiedRotation = inputRotation;
|
||||
}
|
||||
|
||||
[Button("Initialize Settings", ButtonHeight = 30), PropertySpace(10,5 )]
|
||||
void InitAllSettings(){
|
||||
var settingsList = data.GetAllSettings();
|
||||
|
||||
foreach (IResettableSettingValue value in settingsList) {
|
||||
value.Initialize();
|
||||
value.Verify();
|
||||
}
|
||||
}
|
||||
|
||||
void SmoothAllSettings(){
|
||||
var settingsList = data.GetAllSettings();
|
||||
|
||||
foreach (IResettableSettingValue value in settingsList) {
|
||||
value.SmoothAndEase();
|
||||
}
|
||||
}
|
||||
|
||||
public void AddToCurrentDirection(Vector3 inputDirection, float power){ // Old
|
||||
Debug.LogError("Using an old movement command! Switch to one of the new alternatives!");
|
||||
}
|
||||
|
||||
public void SmoothToSpeed(float desiredSpeed, float smoothing){ // Old
|
||||
Debug.LogError("Using an old movement command! Switch to one of the new alternatives!");
|
||||
}
|
||||
|
||||
public void SetNewDirection(Vector3 inputDirection){ // NOTE: If smoothing desired add a default bool for smoothing maybe? // Old
|
||||
Debug.LogError("Using an old movement command! Switch to one of the new alternatives!");
|
||||
}
|
||||
|
||||
public void SetNewGravity(float value){
|
||||
Debug.LogError("Using an old movement command! Switch to one of the new alternatives!");
|
||||
}
|
||||
|
||||
public void OverwriteDirectionFromInput(Vector2 value, float priority, float speed = Mathf.Infinity){ // Old
|
||||
Debug.LogError("Using an old movement command! Switch to one of the new alternatives!");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user