浏览代码

Acceleration/Deceleration for character

/devlogs-4-addressable-assets
Ciro Continisio 4 年前
当前提交
8e91ed4b
共有 4 个文件被更改,包括 370 次插入86 次删除
  1. 20
      UOP1_Project/Assets/Art/Characters/PigChef/Animation/PigChef.controller
  2. 260
      UOP1_Project/Assets/Art/Characters/PigChef/Animation/StaffVariations/Run_withStaff.anim
  3. 146
      UOP1_Project/Assets/Art/Characters/PigChef/Animation/StaffVariations/Walk_withStaff.anim
  4. 30
      UOP1_Project/Assets/Scripts/Characters/Protagonist.cs

20
UOP1_Project/Assets/Art/Characters/PigChef/Animation/PigChef.controller


m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionDuration: 0.1
m_TransitionOffset: 0
m_ExitTime: 0.70000005
m_HasExitTime: 0

m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionDuration: 0.1
m_TransitionOffset: 0
m_ExitTime: 0.70000005
m_HasExitTime: 0

m_Mute: 0
m_IsExit: 1
serializedVersion: 3
m_TransitionDuration: 0.12002003
m_TransitionDuration: 0.1
m_TransitionOffset: 0.00020662394
m_ExitTime: 0.852398
m_HasExitTime: 1

m_Mute: 0
m_IsExit: 1
serializedVersion: 3
m_TransitionDuration: 0.20000017
m_TransitionDuration: 0.1
m_TransitionOffset: 0.00036855336
m_ExitTime: 0.82748896
m_HasExitTime: 1

m_Motion: {fileID: 7400000, guid: 2ed633f741c0b0e47b05f993d698dbf1, type: 2}
m_Threshold: 0
m_Position: {x: 0, y: 0}
m_TimeScale: 0.8
m_TimeScale: 0.5
m_DirectBlendParameter: WalkingSpeed
m_DirectBlendParameter: MovingSpeed
m_Mirror: 0
- serializedVersion: 2
m_Motion: {fileID: 7400000, guid: 2ed633f741c0b0e47b05f993d698dbf1, type: 2}
m_Threshold: 0.5
m_Position: {x: 0, y: 0}
m_TimeScale: 1.2
m_CycleOffset: 0
m_DirectBlendParameter: MovingSpeed
m_Mirror: 0
- serializedVersion: 2
m_Motion: {fileID: 7400000, guid: f26a2dc3f6e948a4d8dd0cae7791fc88, type: 2}

260
UOP1_Project/Assets/Art/Characters/PigChef/Animation/StaffVariations/Run_withStaff.anim


m_PostInfinity: 2
m_RotationOrder: 4
path: Root/Hips/RightApron/RightApronEnd
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: {x: -0.20725635, y: -0.20488954, z: -0.49939957, w: 0.81588304}
inSlope: {x: 0, y: 0, z: 0, w: 0}
outSlope: {x: -0.0007947286, y: -0.00049670535, z: 0.00019868214, w: 0}
tangentMode: 0
weightedMode: 0
inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334, w: 0.33333334}
outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334, w: 0.33333334}
- serializedVersion: 3
time: 0.3
value: {x: -0.27628124, y: -0.24684744, z: -0.48004016, w: 0.7951707}
inSlope: {x: -0.0006953875, y: -0.0004470348, z: 0.00009934107, w: 0}
outSlope: {x: 0.0007152558, y: 0.00040233138, z: -0.00017881395, w: 0.00017881395}
tangentMode: 0
weightedMode: 0
inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334, w: 0.33333334}
outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334, w: 0.33333334}
- serializedVersion: 3
time: 0.6333333
value: {x: -0.20725635, y: -0.20488954, z: -0.49939957, w: 0.81588304}
inSlope: {x: 0.0007152558, y: 0.00044703486, z: -0.00017881395, w: 0}
outSlope: {x: 0, y: 0, z: 0, w: 0}
tangentMode: 0
weightedMode: 0
inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334, w: 0.33333334}
outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334, w: 0.33333334}
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
path: HandsIK/RightHandIK/Controller
m_CompressedRotationCurves: []
m_EulerCurves:
- curve:

m_PostInfinity: 2
m_RotationOrder: 4
path: Root/Hips/Spine/Spine1/Chest/RightShoulder/RightArm/RightForeArm/RightHand/RightHandThumb1/RightHandThumb2/RightHandThumb3
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: {x: -32.877, y: -8.72, z: -60.364}
inSlope: {x: 0, y: 0, z: 0}
outSlope: {x: 0, y: 0, z: 0}
tangentMode: 0
weightedMode: 0
inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334}
outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334}
- serializedVersion: 3
time: 0.3
value: {x: -42.561, y: -9.954, z: -58.353}
inSlope: {x: 0, y: 0, z: 0}
outSlope: {x: 0, y: 0, z: 0}
tangentMode: 0
weightedMode: 0
inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334}
outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334}
- serializedVersion: 3
time: 0.6333333
value: {x: -32.877, y: -8.72, z: -60.364}
inSlope: {x: 0, y: 0, z: 0}
outSlope: {x: 0, y: 0, z: 0}
tangentMode: 0
weightedMode: 0
inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334}
outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334}
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
path: HandsIK/RightHandIK/Controller
m_PositionCurves:
- curve:
serializedVersion: 2

isPPtrCurve: 0
- serializedVersion: 2
path: 1411300718
attribute: 4
attribute: 2
customType: 4
customType: 0
isPPtrCurve: 0
- serializedVersion: 2
path: 3160820590

m_Curve:
- serializedVersion: 3
time: 0
value: -32.877
value: -0.20725635
outSlope: 0
tangentMode: 136
outSlope: -0.0007947286
tangentMode: 0
value: -42.561
inSlope: 0
value: -0.27628124
inSlope: -0.0006953875
outSlope: 0.0007152558
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.6333333
value: -0.20725635
inSlope: 0.0007152558
tangentMode: 136
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_LocalRotation.x
path: HandsIK/RightHandIK/Controller
classID: 4
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: -0.20488954
inSlope: 0
outSlope: -0.00049670535
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.3
value: -0.24684744
inSlope: -0.0004470348
outSlope: 0.00040233138
tangentMode: 0
value: -32.877
inSlope: 0
value: -0.20488954
inSlope: 0.00044703486
tangentMode: 136
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334

attribute: localEulerAnglesRaw.x
attribute: m_LocalRotation.y
path: HandsIK/RightHandIK/Controller
classID: 4
script: {fileID: 0}

- serializedVersion: 3
time: 0
value: -8.72
value: -0.49939957
outSlope: 0
tangentMode: 136
outSlope: 0.00019868214
tangentMode: 0
value: -9.954
inSlope: 0
outSlope: 0
tangentMode: 136
value: -0.48004016
inSlope: 0.00009934107
outSlope: -0.00017881395
tangentMode: 0
value: -8.72
inSlope: 0
value: -0.49939957
inSlope: -0.00017881395
tangentMode: 136
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334

attribute: localEulerAnglesRaw.y
attribute: m_LocalRotation.z
path: HandsIK/RightHandIK/Controller
classID: 4
script: {fileID: 0}

- serializedVersion: 3
time: 0
value: -60.364
value: 0.81588304
tangentMode: 136
tangentMode: 0
value: -58.353
value: 0.7951707
outSlope: 0
tangentMode: 136
outSlope: 0.00017881395
tangentMode: 0
value: -60.364
value: 0.81588304
tangentMode: 136
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334

attribute: localEulerAnglesRaw.z
attribute: m_LocalRotation.w
path: HandsIK/RightHandIK/Controller
classID: 4
script: {fileID: 0}

script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve: []
m_Curve:
- serializedVersion: 3
time: 0
value: -32.877
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.3
value: -42.561
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.6333333
value: -32.877
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
attribute: m_LocalEulerAngles.x
attribute: localEulerAngles.x
m_Curve: []
m_Curve:
- serializedVersion: 3
time: 0
value: -8.72
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.3
value: -9.954
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.6333333
value: -8.72
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
attribute: m_LocalEulerAngles.y
attribute: localEulerAngles.y
m_Curve: []
m_Curve:
- serializedVersion: 3
time: 0
value: -60.364
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.3
value: -58.353
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.6333333
value: -60.364
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
attribute: m_LocalEulerAngles.z
attribute: localEulerAngles.z
path: HandsIK/RightHandIK/Controller
classID: 4
script: {fileID: 0}

146
UOP1_Project/Assets/Art/Characters/PigChef/Animation/StaffVariations/Walk_withStaff.anim


m_PostInfinity: 2
m_RotationOrder: 4
path: Root/Hips/Spine/Spine1/Chest/RightShoulder/RightArm/RightForeArm/RightHand/RightHandThumb1/RightHandThumb2/RightHandThumb3
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: {x: -32.877, y: -8.72, z: -60.364}
inSlope: {x: 0, y: 0, z: 0}
outSlope: {x: 0, y: 0, z: 0}
tangentMode: 0
weightedMode: 0
inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334}
outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334}
- serializedVersion: 3
time: 1
value: {x: -32.877, y: -8.72, z: -60.364}
inSlope: {x: 0, y: 0, z: 0}
outSlope: {x: 0, y: 0, z: 0}
tangentMode: 0
weightedMode: 0
inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334}
outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334}
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
path: HandsIK/RightHandIK/Controller
m_PositionCurves:
- curve:
serializedVersion: 2

isPPtrCurve: 0
- serializedVersion: 2
path: 3369899026
attribute: 4
script: {fileID: 0}
typeID: 4
customType: 4
isPPtrCurve: 0
- serializedVersion: 2
path: 1411300718
attribute: 4
script: {fileID: 0}
typeID: 4

path: Root/Hips/Spine/Spine1/Chest/RightShoulder/RightArm/RightForeArm/RightHand/RightHandThumb1/RightHandThumb2/RightHandThumb3/RightHandThumb4
classID: 4
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: -32.877
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: -32.877
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: localEulerAnglesRaw.x
path: HandsIK/RightHandIK/Controller
classID: 4
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: -8.72
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: -8.72
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: localEulerAnglesRaw.y
path: HandsIK/RightHandIK/Controller
classID: 4
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: -60.364
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: -60.364
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: localEulerAnglesRaw.z
path: HandsIK/RightHandIK/Controller
classID: 4
script: {fileID: 0}
m_EulerEditorCurves:
- curve:
serializedVersion: 2

m_RotationOrder: 4
attribute: m_LocalEulerAngles.z
path: Root/Hips/Spine/Spine1/Chest/RightShoulder/RightArm/RightForeArm/RightHand/RightHandThumb1/RightHandThumb2/RightHandThumb3
classID: 4
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve: []
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_LocalEulerAngles.x
path: HandsIK/RightHandIK/Controller
classID: 4
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve: []
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_LocalEulerAngles.y
path: HandsIK/RightHandIK/Controller
classID: 4
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve: []
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_LocalEulerAngles.z
path: HandsIK/RightHandIK/Controller
classID: 4
script: {fileID: 0}
m_HasGenericRootTransform: 0

30
UOP1_Project/Assets/Scripts/Characters/Protagonist.cs


[SerializeField] private VoidEventChannelSO _openInventoryChannel = default;
private Vector2 _previousMovementInput;
private Vector2 _inputVector;
private float _previousSpeed;
//These fields are read and manipulated by the StateMachine actions
[NonSerialized] public bool jumpInput;

private void RecalculateMovement()
{
float targetSpeed = 0f;
Vector3 adjustedMovement;
if (gameplayCameraTransform.isSet)
{
//Get the two axes from the camera and flatten them on the XZ plane

cameraRight.y = 0f;
//Use the two axes, modulated by the corresponding inputs, and construct the final vector
Vector3 adjustedMovement = cameraRight.normalized * _previousMovementInput.x +
cameraForward.normalized * _previousMovementInput.y;
movementInput = Vector3.ClampMagnitude(adjustedMovement, 1f);
adjustedMovement = cameraRight.normalized * _inputVector.x +
cameraForward.normalized * _inputVector.y;
movementInput = new Vector3(_previousMovementInput.x, 0f, _previousMovementInput.y);
adjustedMovement = new Vector3(_inputVector.x, 0f, _inputVector.y);
//Fix to avoid getting a Vector3.zero vector, which would result in the player turning to x:0, z:0
if(_inputVector.sqrMagnitude == 0f)
adjustedMovement = transform.forward * (adjustedMovement.magnitude + .01f);
//Accelerate/decelerate
targetSpeed = Mathf.Clamp01(_inputVector.magnitude);
if (isRunning)
movementInput.Normalize();
if(targetSpeed > 0f && isRunning) targetSpeed = 1f;
targetSpeed = Mathf.Lerp(_previousSpeed, targetSpeed, Time.deltaTime * 4f);
movementInput = adjustedMovement.normalized * targetSpeed;
_previousSpeed = targetSpeed;
}
//---- EVENT LISTENERS ----

_previousMovementInput = movement;
_inputVector = movement;
}
private void OnJumpInitiated()

正在加载...
取消
保存