Player Animations

This commit is contained in:
Walter
2026-02-01 15:34:36 -06:00
parent 7362c7f57e
commit 1a498ce99d
8 changed files with 94 additions and 36 deletions
+2 -1
View File
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Generated file, do not modify, your changes will be overwritten (use AssetPostprocessor.OnGeneratedCSProject) --> <!-- Generated file, do not modify, your changes will be overwritten (use AssetPostprocessor.OnGeneratedCSProject) -->
<PropertyGroup> <PropertyGroup>
@@ -78,6 +78,7 @@
<Compile Include="Assets\Scripts\CreditsInputHandler.cs" /> <Compile Include="Assets\Scripts\CreditsInputHandler.cs" />
<Compile Include="Assets\Scripts\LoseGuiController.cs" /> <Compile Include="Assets\Scripts\LoseGuiController.cs" />
<Compile Include="Assets\Scripts\HealthGUIController.cs" /> <Compile Include="Assets\Scripts\HealthGUIController.cs" />
<Compile Include="Assets\Scripts\PlayerAnimationController.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="Assets\UI Toolkit\CreditsGUI.uxml" /> <None Include="Assets\UI Toolkit\CreditsGUI.uxml" />
+27 -30
View File
@@ -135,6 +135,31 @@ AnimatorState:
m_MirrorParameter: m_MirrorParameter:
m_CycleOffsetParameter: m_CycleOffsetParameter:
m_TimeParameter: m_TimeParameter:
--- !u!1101 &-6621590539747483612
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: isCollapsed
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: -1210443090960147805}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.7692308
m_HasExitTime: 1
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &-6059084907828803585 --- !u!1101 &-6059084907828803585
AnimatorStateTransition: AnimatorStateTransition:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
@@ -172,6 +197,7 @@ AnimatorState:
m_CycleOffset: 0 m_CycleOffset: 0
m_Transitions: m_Transitions:
- {fileID: 3261478500395500566} - {fileID: 3261478500395500566}
- {fileID: -6621590539747483612}
m_StateMachineBehaviours: [] m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0} m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0 m_IKOnFeet: 0
@@ -251,9 +277,6 @@ AnimatorStateTransition:
- m_ConditionMode: 1 - m_ConditionMode: 1
m_ConditionEvent: isJumping m_ConditionEvent: isJumping
m_EventTreshold: 0 m_EventTreshold: 0
- m_ConditionMode: 2
m_ConditionEvent: isRunning
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0} m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: -5449330869365902308} m_DstState: {fileID: -5449330869365902308}
m_Solo: 0 m_Solo: 0
@@ -303,8 +326,7 @@ AnimatorState:
m_Name: playerCollapse m_Name: playerCollapse
m_Speed: 1 m_Speed: 1
m_CycleOffset: 0 m_CycleOffset: 0
m_Transitions: m_Transitions: []
- {fileID: 7973517625427532113}
m_StateMachineBehaviours: [] m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0} m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0 m_IKOnFeet: 0
@@ -758,28 +780,3 @@ AnimatorStateTransition:
m_InterruptionSource: 0 m_InterruptionSource: 0
m_OrderedInterruption: 1 m_OrderedInterruption: 1
m_CanTransitionToSelf: 1 m_CanTransitionToSelf: 1
--- !u!1101 &7973517625427532113
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 2
m_ConditionEvent: isCollapsed
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 7407206800022927606}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.8148148
m_HasExitTime: 1
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
+13
View File
@@ -17,6 +17,7 @@ GameObject:
- component: {fileID: 3659140714710275197} - component: {fileID: 3659140714710275197}
- component: {fileID: 9133098163257611752} - component: {fileID: 9133098163257611752}
- component: {fileID: 4619270190355407300} - component: {fileID: 4619270190355407300}
- component: {fileID: 72138333084358172}
m_Layer: 6 m_Layer: 6
m_Name: Player m_Name: Player
m_TagString: Untagged m_TagString: Untagged
@@ -275,6 +276,18 @@ Animator:
m_AllowConstantClipSamplingOptimization: 1 m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorStateOnDisable: 0 m_KeepAnimatorStateOnDisable: 0
m_WriteDefaultValuesOnDisable: 0 m_WriteDefaultValuesOnDisable: 0
--- !u!114 &72138333084358172
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3937090937419967315}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fdb391b004c27a64da8f6922aab5512e, type: 3}
m_Name:
m_EditorClassIdentifier: '::'
--- !u!1 &6898135930931977916 --- !u!1 &6898135930931977916
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
+1 -2
View File
@@ -1244,7 +1244,7 @@ AudioSource:
m_PlayOnAwake: 1 m_PlayOnAwake: 1
m_Volume: 1 m_Volume: 1
m_Pitch: 1 m_Pitch: 1
Loop: 0 Loop: 1
Mute: 0 Mute: 0
Spatialize: 0 Spatialize: 0
SpatializePostEffects: 0 SpatializePostEffects: 0
@@ -3033,5 +3033,4 @@ SceneRoots:
- {fileID: 2100000101} - {fileID: 2100000101}
- {fileID: 2200000001} - {fileID: 2200000001}
- {fileID: 491328828} - {fileID: 491328828}
- {fileID: 393625611}
- {fileID: 738367608} - {fileID: 738367608}
@@ -0,0 +1,10 @@
using UnityEngine;
public class PlayerAnimationController : MonoBehaviour
{
// Update is called once per frame
void Update()
{
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: fdb391b004c27a64da8f6922aab5512e
+34 -2
View File
@@ -20,6 +20,7 @@ public class PlayerPlatformerController : MonoBehaviour
private PlayerStressController playerStressController; private PlayerStressController playerStressController;
private PlayerPickupController playerPickupController; private PlayerPickupController playerPickupController;
private Animator animator;
private Rigidbody2D body; private Rigidbody2D body;
private BoxCollider2D bodyCollider; private BoxCollider2D bodyCollider;
@@ -39,6 +40,7 @@ public class PlayerPlatformerController : MonoBehaviour
bodyCollider = GetComponent<BoxCollider2D>(); bodyCollider = GetComponent<BoxCollider2D>();
playerStressController = GetComponent<PlayerStressController>(); playerStressController = GetComponent<PlayerStressController>();
playerPickupController = GetComponent<PlayerPickupController>(); playerPickupController = GetComponent<PlayerPickupController>();
animator = GetComponent<Animator>();
} }
private void OnEnable() private void OnEnable()
@@ -98,6 +100,11 @@ public class PlayerPlatformerController : MonoBehaviour
private void FixedUpdate() private void FixedUpdate()
{ {
if(IsGrounded())
{
animator.SetBool("isJumping", false);
}
if (healAction == null) return; if (healAction == null) return;
currentHealCoolDown++; currentHealCoolDown++;
@@ -117,19 +124,25 @@ public class PlayerPlatformerController : MonoBehaviour
if (healAction.IsPressed()) if (healAction.IsPressed())
{ {
if(playerPickupController.heldObject != null) animator.SetBool("isBreathing", true);
if (playerPickupController.heldObject != null)
{ {
playerPickupController.DropObject(false); playerPickupController.DropObject(false);
} }
if (canHeal) if (canHeal)
{ {
playerStressController.ReduceStress(1f); playerStressController.ReduceStress(3f);
canHeal = false; canHeal = false;
} }
return; return;
} }
else
{
animator.SetBool("isBreathing", false);
}
var input = moveAction.ReadValue<Vector2>(); var input = moveAction.ReadValue<Vector2>();
if (Mathf.Abs(input.x) > 0.01f) if (Mathf.Abs(input.x) > 0.01f)
@@ -139,6 +152,23 @@ public class PlayerPlatformerController : MonoBehaviour
var velocity = body.linearVelocity; var velocity = body.linearVelocity;
velocity.x = input.x * moveSpeed; velocity.x = input.x * moveSpeed;
body.linearVelocity = velocity; body.linearVelocity = velocity;
if(velocity.x != 0)
{
animator.SetBool("isRunning", true);
if (velocity.x > 0 && IsGrounded())
{
transform.localScale = new Vector3(.25f, .25f, .25f);
}
else
{
transform.localScale = new Vector3(-.25f, .25f, .25f);
}
}
else
{
animator.SetBool("isRunning", false);
}
} }
private void OnJumpPerformed(InputAction.CallbackContext context) private void OnJumpPerformed(InputAction.CallbackContext context)
@@ -154,6 +184,8 @@ public class PlayerPlatformerController : MonoBehaviour
velocity.y = 0f; velocity.y = 0f;
body.linearVelocity = velocity; body.linearVelocity = velocity;
body.AddForce(Vector2.up * jumpImpulse, ForceMode2D.Impulse); body.AddForce(Vector2.up * jumpImpulse, ForceMode2D.Impulse);
animator.SetBool("isJumping", true);
} }
private bool ShouldFilterDevices() private bool ShouldFilterDevices()
+4
View File
@@ -7,6 +7,7 @@ using UnityEngine;
public class PlayerStressController : MonoBehaviour public class PlayerStressController : MonoBehaviour
{ {
public PlayerPickupController pickupController; public PlayerPickupController pickupController;
private Animator animator;
[Header("Stress Settings")] [Header("Stress Settings")]
public float currentStress = 0f; public float currentStress = 0f;
@@ -25,6 +26,7 @@ public class PlayerStressController : MonoBehaviour
void Start() void Start()
{ {
animator = GetComponent<Animator>();
// Start the repeating loop // Start the repeating loop
StartCoroutine(StressCheckLoop()); StartCoroutine(StressCheckLoop());
} }
@@ -76,6 +78,8 @@ public class PlayerStressController : MonoBehaviour
{ {
isPanicking = true; isPanicking = true;
animator.SetBool("isCollapsed", true);
Debug.Log("Player is freaking out man!"); Debug.Log("Player is freaking out man!");
// Add effects like screen shake or slowing down the player here // Add effects like screen shake or slowing down the player here
OnPlayerPanic?.Invoke(); // Trigger the panic event OnPlayerPanic?.Invoke(); // Trigger the panic event