Added block animation, script, and keybind. Still need to add animation transitions/triggers.
This commit is contained in:
djkellerman
2025-01-31 11:27:03 -05:00
parent bbaebadbed
commit 36815eb876
8 changed files with 3061 additions and 6 deletions

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -25,6 +25,32 @@ AnimatorStateTransition:
m_InterruptionSource: 0 m_InterruptionSource: 0
m_OrderedInterruption: 1 m_OrderedInterruption: 1
m_CanTransitionToSelf: 1 m_CanTransitionToSelf: 1
--- !u!1102 &-5708178649659260609
AnimatorState:
serializedVersion: 6
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Block
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: 7400000, guid: 92e0316ccb513f04d960c1446ac8f50a, type: 2}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1101 &-3289816270970516984 --- !u!1101 &-3289816270970516984
AnimatorStateTransition: AnimatorStateTransition:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
@@ -96,13 +122,16 @@ AnimatorStateMachine:
- serializedVersion: 1 - serializedVersion: 1
m_State: {fileID: 4390441580030614539} m_State: {fileID: 4390441580030614539}
m_Position: {x: 60, y: 80, z: 0} m_Position: {x: 60, y: 80, z: 0}
- serializedVersion: 1
m_State: {fileID: -5708178649659260609}
m_Position: {x: 60, y: -80, z: 0}
m_ChildStateMachines: [] m_ChildStateMachines: []
m_AnyStateTransitions: m_AnyStateTransitions:
- {fileID: 5263795009836994554} - {fileID: 5263795009836994554}
m_EntryTransitions: [] m_EntryTransitions: []
m_StateMachineTransitions: {} m_StateMachineTransitions: {}
m_StateMachineBehaviours: [] m_StateMachineBehaviours: []
m_AnyStatePosition: {x: 80, y: 0, z: 0} m_AnyStatePosition: {x: 70, y: 0, z: 0}
m_EntryPosition: {x: 890, y: 0, z: 0} m_EntryPosition: {x: 890, y: 0, z: 0}
m_ExitPosition: {x: 800, y: 120, z: 0} m_ExitPosition: {x: 800, y: 120, z: 0}
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0} m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
@@ -206,6 +235,12 @@ AnimatorController:
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 1 m_DefaultBool: 1
m_Controller: {fileID: 9100000} m_Controller: {fileID: 9100000}
- m_Name: Block
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 1
m_Controller: {fileID: 9100000}
m_AnimatorLayers: m_AnimatorLayers:
- serializedVersion: 5 - serializedVersion: 5
m_Name: Base Layer m_Name: Base Layer

View File

@@ -40,6 +40,15 @@
"processors": "", "processors": "",
"interactions": "", "interactions": "",
"initialStateCheck": false "initialStateCheck": false
},
{
"name": "Block",
"type": "Button",
"id": "be945856-bd8c-4925-8ed1-0555831d5f61",
"expectedControlType": "",
"processors": "",
"interactions": "",
"initialStateCheck": false
} }
], ],
"bindings": [ "bindings": [
@@ -251,6 +260,28 @@
"action": "Punch", "action": "Punch",
"isComposite": false, "isComposite": false,
"isPartOfComposite": false "isPartOfComposite": false
},
{
"name": "",
"id": "de623b7f-b30a-44d6-98ff-64faf7825d8f",
"path": "<Keyboard>/q",
"interactions": "",
"processors": "",
"groups": "",
"action": "Block",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "215ac495-a903-4e41-b61a-6d505550788f",
"path": "<Gamepad>/rightShoulder",
"interactions": "",
"processors": "",
"groups": "",
"action": "Block",
"isComposite": false,
"isPartOfComposite": false
} }
] ]
}, },

View File

@@ -298,7 +298,7 @@ Transform:
m_GameObject: {fileID: 1648017802882051395} m_GameObject: {fileID: 1648017802882051395}
serializedVersion: 2 serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0.33692652, w: -0.94153094} m_LocalRotation: {x: -0, y: -0, z: -0.33692652, w: -0.94153094}
m_LocalPosition: {x: 0, y: -0.5, z: 0} m_LocalPosition: {x: -0.0000001937151, y: -0.5000006, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
@@ -432,7 +432,7 @@ Transform:
m_GameObject: {fileID: 1792259794085692571} m_GameObject: {fileID: 1792259794085692571}
serializedVersion: 2 serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0.053876325, w: 0.9985476} m_LocalRotation: {x: -0, y: -0, z: -0.053876325, w: 0.9985476}
m_LocalPosition: {x: 0, y: -0.5, z: 0} m_LocalPosition: {x: 0.00000014901161, y: -0.50000036, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
@@ -668,7 +668,7 @@ Transform:
m_GameObject: {fileID: 3572452013539030063} m_GameObject: {fileID: 3572452013539030063}
serializedVersion: 2 serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 1, w: 0} m_LocalRotation: {x: 0, y: 0, z: 1, w: 0}
m_LocalPosition: {x: 0.048, y: 0.001, z: 0} m_LocalPosition: {x: 0.048000097, y: 0.0010004044, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
@@ -942,7 +942,7 @@ Transform:
m_GameObject: {fileID: 4053418163071482318} m_GameObject: {fileID: 4053418163071482318}
serializedVersion: 2 serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0.074488364, w: 0.9972219} m_LocalRotation: {x: -0, y: -0, z: -0.074488364, w: 0.9972219}
m_LocalPosition: {x: 0, y: -0.5, z: 0} m_LocalPosition: {x: 0.0000020861626, y: -0.5000008, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
@@ -1345,7 +1345,7 @@ Transform:
m_GameObject: {fileID: 5600043765235685887} m_GameObject: {fileID: 5600043765235685887}
serializedVersion: 2 serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: 0.31969908, w: 0.9475191} m_LocalRotation: {x: -0, y: -0, z: 0.31969908, w: 0.9475191}
m_LocalPosition: {x: 0, y: -0.5, z: 0} m_LocalPosition: {x: 0.0000038594007, y: -0.50000393, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []

View File

@@ -33,4 +33,9 @@ public class AnimationPlayer : MonoBehaviour
{ {
animator.SetTrigger("punch"); animator.SetTrigger("punch");
} }
public void Block()
{
animator.SetTrigger("Block");
}
} }

65
Assets/Scripts/Block.cs Normal file
View File

@@ -0,0 +1,65 @@
using UnityEngine;
using UnityEngine.InputSystem;
[RequireComponent(typeof(PlayerInput))]
[RequireComponent(typeof(Animation))]
public class Block : MonoBehaviour
{
public bool cancelable = true;
[SerializeField] private BoxCollider2D blockArea;
private InputActionAsset actions;
private Animation animationComponent;
private void Start()
{
actions = GetComponent<PlayerInput>().actions;
animationComponent = GetComponent<Animation>();
}
private void Update()
{
var blockAction = actions.FindAction("Block");
if (blockAction.triggered)
{
Debug.Log("Block action triggered!");
if (!cancelable) return;
animationComponent.Play("Block");
DisableCancellation();
ActivateBlockArea();
}
else
{
DeactivateBlockArea();
}
}
public void ActivateBlockArea()
{
blockArea.enabled = true;
}
public void DeactivateBlockArea()
{
blockArea.enabled = false;
}
public void DisableCancellation()
{
cancelable = false;
}
public void EnableCancellation()
{
cancelable = true;
}
public bool IsBlocking()
{
return blockArea.enabled;
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: c8c9288561905664eade3f6b2634fc6d