Crouch animation handling

This commit is contained in:
Hazim Bin Ijaz 2025-10-22 20:43:17 +05:00
parent fc55ab8287
commit e5b1e17af8
4 changed files with 94 additions and 0 deletions

View File

@ -253,6 +253,54 @@ Transform:
- {fileID: 2922485409203589583}
m_Father: {fileID: 1820230339230641925}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1388673061806609288
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4734844877585414737}
- component: {fileID: 5477108479324552319}
m_Layer: 8
m_Name: Crouch
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4734844877585414737
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1388673061806609288}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 478135830229270925}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &5477108479324552319
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1388673061806609288}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7ad3db88389646f3be12ba8cf9423b03, type: 3}
m_Name:
m_EditorClassIdentifier:
_node:
Clip: {fileID: 7400000, guid: 232ea7e985150ea47a3885e425ad486f, type: 2}
Speed: 1
IsLooping: 1
--- !u!1 &1559086467479198684
GameObject:
m_ObjectHideFlags: 0
@ -1802,6 +1850,10 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.x
value: -13.667
objectReference: {fileID: 0}
- target: {fileID: 5049986550155715692, guid: c17b47fcacdfc8d4b80809005a2b2555, type: 3}
propertyPath: _crouch
value:
objectReference: {fileID: 5477108479324552319}
- target: {fileID: 5990956033835523603, guid: c17b47fcacdfc8d4b80809005a2b2555, type: 3}
propertyPath: Flags
value: 262145
@ -2077,11 +2129,19 @@ PrefabInstance:
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects:
- targetCorrespondingSourceObject: {fileID: 6061211252752752388, guid: c17b47fcacdfc8d4b80809005a2b2555, type: 3}
insertIndex: -1
addedObject: {fileID: 4734844877585414737}
- targetCorrespondingSourceObject: {fileID: 4348347289748489880, guid: c17b47fcacdfc8d4b80809005a2b2555, type: 3}
insertIndex: -1
addedObject: {fileID: 8390739549500911191}
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: c17b47fcacdfc8d4b80809005a2b2555, type: 3}
--- !u!4 &478135830229270925 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 6061211252752752388, guid: c17b47fcacdfc8d4b80809005a2b2555, type: 3}
m_PrefabInstance: {fileID: 5962503691769372297}
m_PrefabAsset: {fileID: 0}
--- !u!114 &593472071329726145 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 6522195430194241608, guid: c17b47fcacdfc8d4b80809005a2b2555, type: 3}

View File

@ -28,20 +28,38 @@ namespace TPSBR
private DeadState _dead;
[SerializeField]
private JetpackState _jetpack;
[SerializeField][Tooltip("Crouch animation state. Assign your crouch clip/state here.")]
private CrouchState _crouch;
private KCC _kcc;
private Character _character;
// AnimationState INTERFACE
protected override void OnInitialize()
{
_kcc = Controller.GetComponentNoAlloc<KCC>();
_character = Controller.GetComponentNoAlloc<Character>();
}
protected override void OnFixedUpdate()
{
KCCData kccData = _kcc.FixedData;
// Crouch animation handling
if (_crouch != null)
{
bool isCrouched = _character != null && _character.IsCrouched;
if (isCrouched == true && kccData.IsGrounded == true)
{
_crouch.Activate(0.1f);
}
else
{
_crouch.Deactivate(0.1f);
}
}
if (kccData.HasJumped == true)
{
_jump.Activate(0.2f);

View File

@ -0,0 +1,13 @@
namespace TPSBR
{
using Fusion.Addons.AnimationController;
/// <summary>
/// Simple crouch animation state. Uses a single clip.
/// Inherits from ClipState like JetpackState for minimal setup.
/// </summary>
public sealed class CrouchState : ClipState
{
// Intentionally minimal; customization (weapon variants, etc.) can be added later if needed.
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7ad3db88389646f3be12ba8cf9423b03
timeCreated: 1761146617