浏览代码

Added Run and Faint animation for PigChef, implemented Run as BlendTree

/main
Ciro Continisio 4 年前
当前提交
e3f6f31a
共有 12 个文件被更改,包括 2446 次插入7 次删除
  1. 110
      UOP1_Project/Assets/Art/Characters/PigChef/Animation/PigChef.controller
  2. 2
      UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Actions/MoveInTheAir.asset
  3. 2
      UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Actions/MoveOnTheGround.asset
  4. 1
      UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/States/Walking.asset
  5. 1001
      UOP1_Project/Assets/Art/Characters/PigChef/Animation/PigChef_faint.fbx
  6. 129
      UOP1_Project/Assets/Art/Characters/PigChef/Animation/PigChef_faint.fbx.meta
  7. 1001
      UOP1_Project/Assets/Art/Characters/PigChef/Animation/PigChef_run.fbx
  8. 129
      UOP1_Project/Assets/Art/Characters/PigChef/Animation/PigChef_run.fbx.meta
  9. 15
      UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Actions/AnimatorMoveSpeedAction.asset
  10. 8
      UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Actions/AnimatorMoveSpeedAction.asset.meta
  11. 44
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/AnimatorMoveSpeedActionSO.cs
  12. 11
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/AnimatorMoveSpeedActionSO.cs.meta

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


m_Position: {x: 30, y: 300, z: 0}
- serializedVersion: 1
m_State: {fileID: 5995182924539841906}
m_Position: {x: 250, y: 170, z: 0}
m_Position: {x: 270, y: 130, z: 0}
- serializedVersion: 1
m_State: {fileID: 440317740882946628}
m_Position: {x: 270, y: 490, z: 0}

- serializedVersion: 1
m_State: {fileID: 2346626782594886847}
m_Position: {x: -250, y: 160, z: 0}
- serializedVersion: 1
m_State: {fileID: -4333447428942073748}
m_Position: {x: -90, y: 700, z: 0}
m_ChildStateMachines: []
m_AnyStateTransitions:
- {fileID: -5538795969231381003}

m_AnyStatePosition: {x: -340, y: 490, z: 0}
m_EntryPosition: {x: 50, y: 120, z: 0}
m_EntryPosition: {x: 50, y: 40, z: 0}
m_ExitPosition: {x: 800, y: 120, z: 0}
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
m_DefaultState: {fileID: -5457889688521372895}

m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1102 &-4333447428942073748
AnimatorState:
serializedVersion: 5
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Faint
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 6434412210229332969, guid: 8c5d2f78dc797944db3531962c5d18ce,
type: 3}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1101 &-3235251470832908421
AnimatorStateTransition:
m_ObjectHideFlags: 1

m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
- m_Name: HasFainted
m_Type: 4
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
- m_Name: CaneHit
m_Type: 9
m_DefaultFloat: 0

m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
- m_Name: MovingSpeed
m_Type: 1
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer

m_CycleOffset: 0
m_Transitions:
- {fileID: -5864605728144678511}
- {fileID: 6601637620034029229}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0

m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Walk
m_Speed: 1.5
m_Speed: 1
m_CycleOffset: 0
m_Transitions:
- {fileID: 7941493872309352012}

m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: -3419257869308726280, guid: d7866876f824fdd439187217dc8684f0,
type: 3}
m_Motion: {fileID: 8937469675511095552}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:

m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &6601637620034029229
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: HasFainted
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: -4333447428942073748}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.6080562
m_TransitionOffset: 0
m_ExitTime: 0.3951727
m_HasExitTime: 1
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &7395120555452620631
AnimatorStateTransition:
m_ObjectHideFlags: 1

m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!206 &8937469675511095552
BlendTree:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Blend Tree
m_Childs:
- serializedVersion: 2
m_Motion: {fileID: -3419257869308726280, guid: d7866876f824fdd439187217dc8684f0,
type: 3}
m_Threshold: 0
m_Position: {x: 0, y: 0}
m_TimeScale: 1
m_CycleOffset: 0
m_DirectBlendParameter: WalkingSpeed
m_Mirror: 0
- serializedVersion: 2
m_Motion: {fileID: 6200578666267062213, guid: 1da1da422bdf1a54788013b6f1edbd45,
type: 3}
m_Threshold: 0.8
m_Position: {x: 0, y: 0}
m_TimeScale: 1
m_CycleOffset: 0
m_DirectBlendParameter: WalkingSpeed
m_Mirror: 0
m_BlendParameter: MovingSpeed
m_BlendParameterY: Blend
m_MinThreshold: 0
m_MaxThreshold: 0.8
m_UseAutomaticThresholds: 0
m_NormalizedBlendValues: 0
m_BlendType: 0

2
UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Actions/MoveInTheAir.asset


m_Script: {fileID: 11500000, guid: 09fcb347b6cb3524c9f59fbde36ec7c7, type: 3}
m_Name: MoveInTheAir
m_EditorClassIdentifier:
speed: 3.5
speed: 5

2
UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Actions/MoveOnTheGround.asset


m_Script: {fileID: 11500000, guid: 09fcb347b6cb3524c9f59fbde36ec7c7, type: 3}
m_Name: MoveOnTheGround
m_EditorClassIdentifier:
speed: 4
speed: 7

1
UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/States/Walking.asset


- {fileID: 11400000, guid: 47d9da417e68970419335f80f4395239, type: 2}
- {fileID: 11400000, guid: 096d532f9a47f3145892efa1c4322e72, type: 2}
- {fileID: 11400000, guid: fa0ce5b895dcf17499819f0d6f2dce96, type: 2}
- {fileID: 11400000, guid: 5aac41c53e47f1040a52303b2000ceb5, type: 2}

1001
UOP1_Project/Assets/Art/Characters/PigChef/Animation/PigChef_faint.fbx
文件差异内容过多而无法显示
查看文件

129
UOP1_Project/Assets/Art/Characters/PigChef/Animation/PigChef_faint.fbx.meta


fileFormatVersion: 2
guid: 8c5d2f78dc797944db3531962c5d18ce
ModelImporter:
serializedVersion: 19301
internalIDToNameTable:
- first:
74: 6434412210229332969
second: faint
externalObjects: {}
materials:
materialImportMode: 0
materialName: 0
materialSearch: 1
materialLocation: 1
animations:
legacyGenerateAnimations: 4
bakeSimulation: 0
resampleCurves: 1
optimizeGameObjects: 0
motionNodeName:
rigImportErrors:
rigImportWarnings:
animationImportErrors:
animationImportWarnings:
animationRetargetingWarnings:
animationDoRetargetingWarnings: 0
importAnimatedCustomProperties: 0
importConstraints: 0
animationCompression: 1
animationRotationError: 0.5
animationPositionError: 0.5
animationScaleError: 0.5
animationWrapMode: 0
extraExposedTransformPaths: []
extraUserProperties: []
clipAnimations:
- serializedVersion: 16
name: faint
takeName: faint
internalID: 0
firstFrame: 1
lastFrame: 71
wrapMode: 0
orientationOffsetY: 0
level: 0
cycleOffset: 0
loop: 0
hasAdditiveReferencePose: 0
loopTime: 0
loopBlend: 0
loopBlendOrientation: 0
loopBlendPositionY: 0
loopBlendPositionXZ: 0
keepOriginalOrientation: 0
keepOriginalPositionY: 1
keepOriginalPositionXZ: 0
heightFromFeet: 0
mirror: 0
bodyMask: 01000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000
curves: []
events: []
transformMask: []
maskType: 3
maskSource: {instanceID: 0}
additiveReferencePoseFrame: 0
isReadable: 0
meshes:
lODScreenPercentages: []
globalScale: 1
meshCompression: 0
addColliders: 0
useSRGBMaterialColor: 1
sortHierarchyByName: 1
importVisibility: 1
importBlendShapes: 1
importCameras: 1
importLights: 1
fileIdsGeneration: 2
swapUVChannels: 0
generateSecondaryUV: 1
useFileUnits: 1
keepQuads: 0
weldVertices: 1
preserveHierarchy: 0
skinWeightsMode: 0
maxBonesPerVertex: 4
minBoneWeight: 0.001
meshOptimizationFlags: -1
indexFormat: 0
secondaryUVAngleDistortion: 8
secondaryUVAreaDistortion: 15
secondaryUVHardAngle: 88
secondaryUVPackMargin: 8
useFileScale: 1
tangentSpace:
normalSmoothAngle: 60
normalImportMode: 0
tangentImportMode: 3
normalCalculationMode: 4
legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0
blendShapeNormalImportMode: 1
normalSmoothingSource: 0
referencedClips: []
importAnimation: 1
humanDescription:
serializedVersion: 3
human: []
skeleton: []
armTwist: 0.5
foreArmTwist: 0.5
upperLegTwist: 0.5
legTwist: 0.5
armStretch: 0.05
legStretch: 0.05
feetSpacing: 0
globalScale: 1
rootMotionBoneName:
hasTranslationDoF: 0
hasExtraRoot: 0
skeletonHasParents: 1
lastHumanDescriptionAvatarSource: {instanceID: 0}
autoGenerateAvatarMappingIfUnspecified: 1
animationType: 2
humanoidOversampling: 1
avatarSetup: 0
additionalBone: 0
userData:
assetBundleName:
assetBundleVariant:

1001
UOP1_Project/Assets/Art/Characters/PigChef/Animation/PigChef_run.fbx
文件差异内容过多而无法显示
查看文件

129
UOP1_Project/Assets/Art/Characters/PigChef/Animation/PigChef_run.fbx.meta


fileFormatVersion: 2
guid: 1da1da422bdf1a54788013b6f1edbd45
ModelImporter:
serializedVersion: 19301
internalIDToNameTable:
- first:
74: 6200578666267062213
second: run
externalObjects: {}
materials:
materialImportMode: 0
materialName: 0
materialSearch: 1
materialLocation: 1
animations:
legacyGenerateAnimations: 4
bakeSimulation: 0
resampleCurves: 1
optimizeGameObjects: 0
motionNodeName:
rigImportErrors:
rigImportWarnings:
animationImportErrors:
animationImportWarnings:
animationRetargetingWarnings:
animationDoRetargetingWarnings: 0
importAnimatedCustomProperties: 0
importConstraints: 0
animationCompression: 1
animationRotationError: 0.5
animationPositionError: 0.5
animationScaleError: 0.5
animationWrapMode: 0
extraExposedTransformPaths: []
extraUserProperties: []
clipAnimations:
- serializedVersion: 16
name: run
takeName: run
internalID: 0
firstFrame: 1
lastFrame: 20
wrapMode: 0
orientationOffsetY: 0
level: 0
cycleOffset: 0.5
loop: 0
hasAdditiveReferencePose: 0
loopTime: 1
loopBlend: 0
loopBlendOrientation: 0
loopBlendPositionY: 0
loopBlendPositionXZ: 0
keepOriginalOrientation: 0
keepOriginalPositionY: 1
keepOriginalPositionXZ: 0
heightFromFeet: 0
mirror: 0
bodyMask: 01000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000
curves: []
events: []
transformMask: []
maskType: 3
maskSource: {instanceID: 0}
additiveReferencePoseFrame: 0
isReadable: 0
meshes:
lODScreenPercentages: []
globalScale: 1
meshCompression: 0
addColliders: 0
useSRGBMaterialColor: 1
sortHierarchyByName: 1
importVisibility: 1
importBlendShapes: 1
importCameras: 1
importLights: 1
fileIdsGeneration: 2
swapUVChannels: 0
generateSecondaryUV: 0
useFileUnits: 1
keepQuads: 0
weldVertices: 1
preserveHierarchy: 0
skinWeightsMode: 0
maxBonesPerVertex: 4
minBoneWeight: 0.001
meshOptimizationFlags: -1
indexFormat: 0
secondaryUVAngleDistortion: 8
secondaryUVAreaDistortion: 15
secondaryUVHardAngle: 88
secondaryUVPackMargin: 8
useFileScale: 1
tangentSpace:
normalSmoothAngle: 60
normalImportMode: 0
tangentImportMode: 3
normalCalculationMode: 4
legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0
blendShapeNormalImportMode: 1
normalSmoothingSource: 0
referencedClips: []
importAnimation: 1
humanDescription:
serializedVersion: 3
human: []
skeleton: []
armTwist: 0.5
foreArmTwist: 0.5
upperLegTwist: 0.5
legTwist: 0.5
armStretch: 0.05
legStretch: 0.05
feetSpacing: 0
globalScale: 1
rootMotionBoneName:
hasTranslationDoF: 0
hasExtraRoot: 0
skeletonHasParents: 1
lastHumanDescriptionAvatarSource: {instanceID: 0}
autoGenerateAvatarMappingIfUnspecified: 1
animationType: 2
humanoidOversampling: 1
avatarSetup: 0
additionalBone: 0
userData:
assetBundleName:
assetBundleVariant:

15
UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Actions/AnimatorMoveSpeedAction.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 89b354c39b5e27d4b974ab1569e800b8, type: 3}
m_Name: AnimatorMoveSpeedAction
m_EditorClassIdentifier:
parameterName: MovingSpeed

8
UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Actions/AnimatorMoveSpeedAction.asset.meta


fileFormatVersion: 2
guid: 5aac41c53e47f1040a52303b2000ceb5
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

44
UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/AnimatorMoveSpeedActionSO.cs


using System;
using UnityEngine;
using UOP1.StateMachine;
using UOP1.StateMachine.ScriptableObjects;
using Moment = UOP1.StateMachine.StateAction.SpecificMoment;
/// <summary>
/// Flexible StateActionSO for the StateMachine which allows to set any parameter on the Animator, in any moment of the state (OnStateEnter, OnStateExit, or each OnUpdate).
/// </summary>
[CreateAssetMenu(fileName = "AnimatorMoveSpeedAction", menuName = "State Machines/Actions/Set Animator Move Speed")]
public class AnimatorMoveSpeedActionSO : StateActionSO
{
public string parameterName = default;
protected override StateAction CreateAction() => new AnimatorMoveSpeedAction(Animator.StringToHash(parameterName));
}
public class AnimatorMoveSpeedAction : StateAction
{
//Component references
private Animator _animator;
private Protagonist _protagonist;
private AnimatorParameterActionSO _originSO => (AnimatorParameterActionSO)base.OriginSO; // The SO this StateAction spawned from
private int _parameterHash;
public AnimatorMoveSpeedAction(int parameterHash)
{
_parameterHash = parameterHash;
}
public override void Awake(StateMachine stateMachine)
{
_animator = stateMachine.GetComponent<Animator>();
_protagonist = stateMachine.GetComponent<Protagonist>();
}
public override void OnUpdate()
{
//TODO: do we like that we're using the magnitude here, per frame? Can this be done in a smarter way?
float normalisedSpeed = _protagonist.movementInput.magnitude;
_animator.SetFloat(_parameterHash, normalisedSpeed);
}
}

11
UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/AnimatorMoveSpeedActionSO.cs.meta


fileFormatVersion: 2
guid: 89b354c39b5e27d4b974ab1569e800b8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存