Rename some animation stuff and make crab animations proper

This commit is contained in:
Sofia 2019-08-14 17:32:52 +03:00
parent 3b865bbd13
commit e083092dff
24 changed files with 323 additions and 35 deletions

View File

@ -0,0 +1,107 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1107 &-2283372574418785537
AnimatorStateMachine:
serializedVersion: 5
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Base Layer
m_ChildStates:
- serializedVersion: 1
m_State: {fileID: -626156007799306927}
m_Position: {x: 310, y: 50, z: 0}
- serializedVersion: 1
m_State: {fileID: 3988067699168050806}
m_Position: {x: 300, y: 160, z: 0}
m_ChildStateMachines: []
m_AnyStateTransitions: []
m_EntryTransitions: []
m_StateMachineTransitions: {}
m_StateMachineBehaviours: []
m_AnyStatePosition: {x: 50, y: 20, z: 0}
m_EntryPosition: {x: 50, y: 120, z: 0}
m_ExitPosition: {x: 800, y: 120, z: 0}
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
m_DefaultState: {fileID: -626156007799306927}
--- !u!1102 &-626156007799306927
AnimatorState:
serializedVersion: 5
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: CrabWalk
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: 1
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: d44cb1f5286be4944bd87a16d2c3d1c6, type: 2}
m_Tag:
m_SpeedParameter: Speed
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!91 &9100000
AnimatorController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Crab
serializedVersion: 5
m_AnimatorParameters:
- m_Name: Speed
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_StateMachine: {fileID: -2283372574418785537}
m_Mask: {fileID: 0}
m_Motions: []
m_Behaviours: []
m_BlendingMode: 0
m_SyncedLayerIndex: -1
m_DefaultWeight: 0
m_IKPass: 0
m_SyncedLayerAffectsTiming: 0
m_Controller: {fileID: 9100000}
--- !u!1102 &3988067699168050806
AnimatorState:
serializedVersion: 5
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: CrabAttack
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: 1
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: cf3e7fccde276d94aa91734e92754725, type: 2}
m_Tag:
m_SpeedParameter: Speed
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 460c3467220797a408662eba56385be7
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 9100000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,69 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!74 &7400000
AnimationClip:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: CrabAttack
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
m_RotationCurves: []
m_CompressedRotationCurves: []
m_EulerCurves: []
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves: []
m_PPtrCurves:
- curve:
- time: 0
value: {fileID: 3837973818445772063, guid: 8d816068e3260f54f9cb041dcd165103,
type: 3}
attribute: m_Sprite
path:
classID: 212
script: {fileID: 0}
m_SampleRate: 12
m_WrapMode: 0
m_Bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings:
- serializedVersion: 2
path: 0
attribute: 0
script: {fileID: 0}
typeID: 212
customType: 23
isPPtrCurve: 1
pptrCurveMapping:
- {fileID: 3837973818445772063, guid: 8d816068e3260f54f9cb041dcd165103, type: 3}
m_AnimationClipSettings:
serializedVersion: 2
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 0.083333336
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 1
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
m_LoopBlendPositionXZ: 0
m_KeepOriginalOrientation: 0
m_KeepOriginalPositionY: 1
m_KeepOriginalPositionXZ: 0
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves: []
m_EulerEditorCurves: []
m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0
m_Events: []

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: cf3e7fccde276d94aa91734e92754725
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,77 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!74 &7400000
AnimationClip:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: CrabWalk
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
m_RotationCurves: []
m_CompressedRotationCurves: []
m_EulerCurves: []
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves: []
m_PPtrCurves:
- curve:
- time: 0
value: {fileID: 6754164815184778395, guid: 8d816068e3260f54f9cb041dcd165103,
type: 3}
- time: 0.25
value: {fileID: -8236523633242920872, guid: 8d816068e3260f54f9cb041dcd165103,
type: 3}
- time: 0.5
value: {fileID: 6754164815184778395, guid: 8d816068e3260f54f9cb041dcd165103,
type: 3}
attribute: m_Sprite
path:
classID: 212
script: {fileID: 0}
m_SampleRate: 12
m_WrapMode: 0
m_Bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings:
- serializedVersion: 2
path: 0
attribute: 0
script: {fileID: 0}
typeID: 212
customType: 23
isPPtrCurve: 1
pptrCurveMapping:
- {fileID: 6754164815184778395, guid: 8d816068e3260f54f9cb041dcd165103, type: 3}
- {fileID: -8236523633242920872, guid: 8d816068e3260f54f9cb041dcd165103, type: 3}
- {fileID: 6754164815184778395, guid: 8d816068e3260f54f9cb041dcd165103, type: 3}
m_AnimationClipSettings:
serializedVersion: 2
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 0.5833333
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 1
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
m_LoopBlendPositionXZ: 0
m_KeepOriginalOrientation: 0
m_KeepOriginalPositionY: 1
m_KeepOriginalPositionXZ: 0
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves: []
m_EulerEditorCurves: []
m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0
m_Events: []

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d44cb1f5286be4944bd87a16d2c3d1c6
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -57,7 +57,7 @@ AnimatorController:
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_Name: BodyAnim m_Name: PlayerBodyAnim
serializedVersion: 5 serializedVersion: 5
m_AnimatorParameters: m_AnimatorParameters:
- m_Name: Speed - m_Name: Speed
@ -65,7 +65,7 @@ AnimatorController:
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
m_AnimatorLayers: m_AnimatorLayers:
- serializedVersion: 5 - serializedVersion: 5
m_Name: Base Layer m_Name: Base Layer

View File

@ -32,7 +32,7 @@ AnimatorController:
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_Name: HeadAnim m_Name: PlayerHeadAnim
serializedVersion: 5 serializedVersion: 5
m_AnimatorParameters: m_AnimatorParameters:
- m_Name: Speed - m_Name: Speed
@ -40,7 +40,7 @@ AnimatorController:
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
m_AnimatorLayers: m_AnimatorLayers:
- serializedVersion: 5 - serializedVersion: 5
m_Name: Base Layer m_Name: Base Layer

View File

@ -6,7 +6,7 @@ AnimationClip:
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_Name: HeadDown m_Name: PlayerHeadDown
serializedVersion: 6 serializedVersion: 6
m_Legacy: 0 m_Legacy: 0
m_Compressed: 0 m_Compressed: 0

View File

@ -6,7 +6,7 @@ AnimationClip:
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_Name: HeadRight m_Name: PlayerHeadRight
serializedVersion: 6 serializedVersion: 6
m_Legacy: 0 m_Legacy: 0
m_Compressed: 0 m_Compressed: 0

View File

@ -6,7 +6,7 @@ AnimationClip:
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_Name: HeadUp m_Name: PlayerHeadUp
serializedVersion: 6 serializedVersion: 6
m_Legacy: 0 m_Legacy: 0
m_Compressed: 0 m_Compressed: 0

View File

@ -6,7 +6,7 @@ AnimationClip:
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_Name: HorizontalBody m_Name: PlayerHorizontalBody
serializedVersion: 6 serializedVersion: 6
m_Legacy: 0 m_Legacy: 0
m_Compressed: 0 m_Compressed: 0

View File

@ -6,7 +6,7 @@ AnimationClip:
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_Name: VerticalBody m_Name: PlayerVerticalBody
serializedVersion: 6 serializedVersion: 6
m_Legacy: 0 m_Legacy: 0
m_Compressed: 0 m_Compressed: 0

View File

@ -57,15 +57,7 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
CurrentBehavior: Nothing CurrentBehavior: Nothing
Renderer: {fileID: 592487111066334295} Anim: {fileID: 5375970501711434365}
IdleSprite: {fileID: 6754164815184778395, guid: 8d816068e3260f54f9cb041dcd165103,
type: 3}
AttackingSprite: {fileID: 3837973818445772063, guid: 8d816068e3260f54f9cb041dcd165103,
type: 3}
MovementAnimationFramerate: 8
MovementSprites:
- {fileID: 6754164815184778395, guid: 8d816068e3260f54f9cb041dcd165103, type: 3}
- {fileID: -8236523633242920872, guid: 8d816068e3260f54f9cb041dcd165103, type: 3}
MoveSpeed: 1 MoveSpeed: 1
BehaviourTree: {fileID: 592487110401094199} BehaviourTree: {fileID: 592487110401094199}
Attacking: 0 Attacking: 0
@ -133,6 +125,7 @@ MonoBehaviour:
- {fileID: 960737912245282743, guid: 2fb0a649165a8b7429b09809cd8e25c7, type: 3} - {fileID: 960737912245282743, guid: 2fb0a649165a8b7429b09809cd8e25c7, type: 3}
- {fileID: 3610142911819508080, guid: a1affae9e5ef819468fdc1f18f63ca7e, type: 3} - {fileID: 3610142911819508080, guid: a1affae9e5ef819468fdc1f18f63ca7e, type: 3}
DebugExplode: 0 DebugExplode: 0
KillOnZeroHealth: 1
--- !u!114 &3362493323285318061 --- !u!114 &3362493323285318061
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -282,6 +275,7 @@ GameObject:
m_Component: m_Component:
- component: {fileID: 592487111066334294} - component: {fileID: 592487111066334294}
- component: {fileID: 592487111066334295} - component: {fileID: 592487111066334295}
- component: {fileID: 5375970501711434365}
m_Layer: 0 m_Layer: 0
m_Name: Sprite m_Name: Sprite
m_TagString: Untagged m_TagString: Untagged
@ -353,6 +347,25 @@ SpriteRenderer:
m_WasSpriteAssigned: 1 m_WasSpriteAssigned: 1
m_MaskInteraction: 0 m_MaskInteraction: 0
m_SpriteSortPoint: 0 m_SpriteSortPoint: 0
--- !u!95 &5375970501711434365
Animator:
serializedVersion: 3
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 592487111066334293}
m_Enabled: 1
m_Avatar: {fileID: 0}
m_Controller: {fileID: 9100000, guid: 460c3467220797a408662eba56385be7, type: 2}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorControllerStateOnDisable: 0
--- !u!1 &592487111173795459 --- !u!1 &592487111173795459
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -363,7 +376,7 @@ GameObject:
m_Component: m_Component:
- component: {fileID: 592487111173795460} - component: {fileID: 592487111173795460}
m_Layer: 0 m_Layer: 0
m_Name: AnimationRoot m_Name: AttackingRoot
m_TagString: Untagged m_TagString: Untagged
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0

View File

@ -1,4 +1,5 @@
using UnityEngine; using UnityEngine;
using UnityEngine.Animations;
using Saltosion.OneWeapon.AI; using Saltosion.OneWeapon.AI;
namespace Saltosion.OneWeapon.Enemies { namespace Saltosion.OneWeapon.Enemies {
@ -7,11 +8,7 @@ namespace Saltosion.OneWeapon.Enemies {
[Header("Debug Info")] [Header("Debug Info")]
public string CurrentBehavior = "Nothing"; public string CurrentBehavior = "Nothing";
[Header("Graphics")] [Header("Graphics")]
public SpriteRenderer Renderer; public Animator Anim;
public Sprite IdleSprite;
public Sprite AttackingSprite;
public int MovementAnimationFramerate;
public Sprite[] MovementSprites;
[Header("Stats")] [Header("Stats")]
public float MoveSpeed; public float MoveSpeed;
[Header("Behaviour")] [Header("Behaviour")]
@ -33,11 +30,13 @@ namespace Saltosion.OneWeapon.Enemies {
CurrentBehavior = BehaviourTree.GetExecutedName(); CurrentBehavior = BehaviourTree.GetExecutedName();
if (Attacking) { if (Attacking) {
Renderer.sprite = AttackingSprite; Anim.Play("CrabAttack");
} else if (Body.velocity.magnitude > 0.1) { } else if (Body.velocity.magnitude > 0.1) {
Renderer.sprite = MovementSprites[(int)(Time.time * MovementAnimationFramerate) % MovementSprites.Length]; Anim.Play("CrabWalk");
Anim.SetFloat("Speed", 1);
} else { } else {
Renderer.sprite = IdleSprite; Anim.Play("CrabWalk");
Anim.SetFloat("Speed", 0);
} }
} }

View File

@ -63,26 +63,26 @@ namespace Saltosion.OneWeapon.Player {
float Rotation = Rot.z; float Rotation = Rot.z;
if (Rotation >= 45 && Rotation < 135) { if (Rotation >= 45 && Rotation < 135) {
BodyAnim.Play("HorizontalBody"); BodyAnim.Play("PlayerHorizontalBody");
BodySprite.flipX = false; BodySprite.flipX = false;
HeadAnim.Play("HeadRight"); HeadAnim.Play("PlayerHeadRight");
HeadSprite.flipX = false; HeadSprite.flipX = false;
Hand.localPosition = HandMiddle.localPosition; Hand.localPosition = HandMiddle.localPosition;
} else if (Rotation >= 225 || Rotation < -45) { } else if (Rotation >= 225 || Rotation < -45) {
BodyAnim.Play("HorizontalBody"); BodyAnim.Play("PlayerHorizontalBody");
BodySprite.flipX = true; BodySprite.flipX = true;
HeadAnim.Play("HeadRight"); HeadAnim.Play("PlayerHeadRight");
HeadSprite.flipX = true; HeadSprite.flipX = true;
Hand.localPosition = HandMiddle.localPosition; Hand.localPosition = HandMiddle.localPosition;
} else { } else {
if (Rotation >= 135 && Rotation < 225) { if (Rotation >= 135 && Rotation < 225) {
HeadAnim.Play("HeadUp"); HeadAnim.Play("PlayerHeadUp");
Hand.localPosition = HandRight.localPosition; Hand.localPosition = HandRight.localPosition;
} else { } else {
HeadAnim.Play("HeadDown"); HeadAnim.Play("PlayerHeadDown");
Hand.localPosition = HandLeft.localPosition; Hand.localPosition = HandLeft.localPosition;
} }
BodyAnim.Play("VerticalBody"); BodyAnim.Play("PlayerVerticalBody");
BodySprite.flipX = false; BodySprite.flipX = false;
HeadSprite.flipX = false; HeadSprite.flipX = false;
} }

View File

@ -25,7 +25,6 @@ namespace Saltosion.OneWeapon.Utils {
CurrentSpeed -= AccelerationSpeed * Time.deltaTime; CurrentSpeed -= AccelerationSpeed * Time.deltaTime;
} }
CurrentSpeed *= 1 - (Vector2.Angle(Direction, LastDirection) / 180); CurrentSpeed *= 1 - (Vector2.Angle(Direction, LastDirection) / 180);
Debug.Log(1 - (Vector2.Angle(Direction, LastDirection) / 180));
CurrentSpeed = Mathf.Clamp(CurrentSpeed, 0, MaxSpeed); CurrentSpeed = Mathf.Clamp(CurrentSpeed, 0, MaxSpeed);
SpeedPercentage = CurrentSpeed / MaxSpeed; SpeedPercentage = CurrentSpeed / MaxSpeed;