From bdfb6793e9371755f1471978b1a13b017aed8dbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C5=A1a=20Ceviel?= Date: Mon, 2 Feb 2026 17:25:38 +0300 Subject: [PATCH] fixing animations --- Assets/Code/Gameplay/Player/PlayerMovement.cs | 22 +++++++++++++--- .../Animations/penguin_jump.anim | 10 ++++---- .../Animations/penguin_jump_01.controller | 25 +------------------ ProjectSettings/ProjectSettings.asset | 4 +-- 4 files changed, 26 insertions(+), 35 deletions(-) diff --git a/Assets/Code/Gameplay/Player/PlayerMovement.cs b/Assets/Code/Gameplay/Player/PlayerMovement.cs index 582bb57..e60344b 100644 --- a/Assets/Code/Gameplay/Player/PlayerMovement.cs +++ b/Assets/Code/Gameplay/Player/PlayerMovement.cs @@ -21,11 +21,19 @@ namespace Code.Gameplay.Player private bool _isJumping; private float _jumpTimer; + private RuntimeAnimatorController _idleAnimator; + private RuntimeAnimatorController _walkAnimator; + private RuntimeAnimatorController _jumpAnimator; + public bool isGrounded { get; private set; } public void Construct(IInputService input) { _input = input; + _animator.runtimeAnimatorController = null; + _idleAnimator = Resources.Load("Animations/penguin_idle_01"); + _walkAnimator = Resources.Load("Animations/penguin_walk_01"); + _jumpAnimator = Resources.Load("Animations/penguin_jump_01"); } private void Update() @@ -78,11 +86,17 @@ namespace Code.Gameplay.Player var isJumping = !isGrounded; if (isJumping) - _animator.runtimeAnimatorController = Resources.Load("Animations/penguin_jump_01"); + { + if (_animator.runtimeAnimatorController != _jumpAnimator) + _animator.runtimeAnimatorController = _jumpAnimator; + } else if (isMoving) - _animator.runtimeAnimatorController = Resources.Load("Animations/penguin_walk_01"); - else - _animator.runtimeAnimatorController = Resources.Load("Animations/penguin_idle_01"); + { + if (_animator.runtimeAnimatorController != _walkAnimator) + _animator.runtimeAnimatorController = _walkAnimator; + } + else if (_animator.runtimeAnimatorController != _idleAnimator) + _animator.runtimeAnimatorController = _idleAnimator; } private void CheckGround() diff --git a/Assets/Nine Pines Animation/2D Character Sprite Animation - Penguin/Animations/penguin_jump.anim b/Assets/Nine Pines Animation/2D Character Sprite Animation - Penguin/Animations/penguin_jump.anim index 33b0ae4..332dde1 100644 --- a/Assets/Nine Pines Animation/2D Character Sprite Animation - Penguin/Animations/penguin_jump.anim +++ b/Assets/Nine Pines Animation/2D Character Sprite Animation - Penguin/Animations/penguin_jump.anim @@ -21,11 +21,11 @@ AnimationClip: - serializedVersion: 2 curve: - time: 0 - value: {fileID: 21300000, guid: d00a97fec0ddfde49bb6a9ae8d67a45b, type: 3} + value: {fileID: 21300000, guid: ee1a12069c8273149801819a62088d65, type: 3} - time: 0.083333336 value: {fileID: 21300000, guid: 371145ea5533f274aa6550d168f1bf4c, type: 3} - time: 0.16666667 - value: {fileID: 21300000, guid: ee1a12069c8273149801819a62088d65, type: 3} + value: {fileID: 21300000, guid: d00a97fec0ddfde49bb6a9ae8d67a45b, type: 3} attribute: m_Sprite path: classID: 212 @@ -48,9 +48,9 @@ AnimationClip: isIntCurve: 0 isSerializeReferenceCurve: 0 pptrCurveMapping: - - {fileID: 21300000, guid: d00a97fec0ddfde49bb6a9ae8d67a45b, type: 3} - - {fileID: 21300000, guid: 371145ea5533f274aa6550d168f1bf4c, type: 3} - {fileID: 21300000, guid: ee1a12069c8273149801819a62088d65, type: 3} + - {fileID: 21300000, guid: 371145ea5533f274aa6550d168f1bf4c, type: 3} + - {fileID: 21300000, guid: d00a97fec0ddfde49bb6a9ae8d67a45b, type: 3} m_AnimationClipSettings: serializedVersion: 2 m_AdditiveReferencePoseClip: {fileID: 0} @@ -61,7 +61,7 @@ AnimationClip: m_Level: 0 m_CycleOffset: 0 m_HasAdditiveReferencePose: 0 - m_LoopTime: 1 + m_LoopTime: 0 m_LoopBlend: 0 m_LoopBlendOrientation: 0 m_LoopBlendPositionY: 0 diff --git a/Assets/Resources/Animations/penguin_jump_01.controller b/Assets/Resources/Animations/penguin_jump_01.controller index 0f4a741..d40d0f6 100644 --- a/Assets/Resources/Animations/penguin_jump_01.controller +++ b/Assets/Resources/Animations/penguin_jump_01.controller @@ -10,8 +10,7 @@ AnimatorState: m_Name: penguin_jump m_Speed: 1 m_CycleOffset: 0 - m_Transitions: - - {fileID: -3647009844017617733} + m_Transitions: [] m_StateMachineBehaviours: [] m_Position: {x: 50, y: 50, z: 0} m_IKOnFeet: 0 @@ -27,28 +26,6 @@ AnimatorState: m_MirrorParameter: m_CycleOffsetParameter: m_TimeParameter: ---- !u!1101 &-3647009844017617733 -AnimatorStateTransition: - m_ObjectHideFlags: 1 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_Name: - m_Conditions: [] - m_DstStateMachine: {fileID: 0} - m_DstState: {fileID: 0} - m_Solo: 0 - m_Mute: 0 - m_IsExit: 1 - serializedVersion: 3 - m_TransitionDuration: 0.25 - m_TransitionOffset: 0 - m_ExitTime: 0 - m_HasExitTime: 1 - m_HasFixedDuration: 1 - m_InterruptionSource: 0 - m_OrderedInterruption: 1 - m_CanTransitionToSelf: 1 --- !u!91 &9100000 AnimatorController: m_ObjectHideFlags: 0 diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 7a111e0..9f429d9 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -302,8 +302,8 @@ PlayerSettings: m_BuildTargetGraphicsJobMode: [] m_BuildTargetGraphicsAPIs: - m_BuildTarget: LinuxStandaloneSupport - m_APIs: 1500000011000000 - m_Automatic: 0 + m_APIs: 1100000015000000 + m_Automatic: 1 m_BuildTargetVRSettings: [] m_DefaultShaderChunkSizeInMB: 16 m_DefaultShaderChunkCount: 0