added enemy dead animation

This commit is contained in:
Mausham
2025-12-30 17:51:20 -08:00
parent 0ec69f66c9
commit b59d12631f
16 changed files with 41248 additions and 54 deletions

View File

@@ -63,7 +63,7 @@ AnimatorStateMachine:
m_ChildStates:
- serializedVersion: 1
m_State: {fileID: 2061396788387956441}
m_Position: {x: 380, y: 250, z: 0}
m_Position: {x: 400, y: 250, z: 0}
- serializedVersion: 1
m_State: {fileID: -8544423869887076905}
m_Position: {x: 401, y: 119, z: 0}
@@ -87,7 +87,8 @@ AnimatorState:
m_Name: SoldierIdle
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
m_Transitions:
- {fileID: 371581830578625903}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
@@ -118,6 +119,12 @@ AnimatorController:
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
- m_Name: Death
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer
@@ -143,6 +150,31 @@ AnimatorController:
m_IKPass: 0
m_SyncedLayerAffectsTiming: 0
m_Controller: {fileID: 9100000}
--- !u!1101 &371581830578625903
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: Death
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 3137088567961274854}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.88095236
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1102 &2061396788387956441
AnimatorState:
serializedVersion: 6
@@ -170,6 +202,32 @@ AnimatorState:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1102 &3137088567961274854
AnimatorState:
serializedVersion: 6
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Death
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: -203655887218126122, guid: 695d002480b40e24195fe09dd3a7fc6f, type: 3}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1101 &6731833491236309845
AnimatorStateTransition:
m_ObjectHideFlags: 1
@@ -203,7 +261,10 @@ AnimatorStateMachine:
m_ChildStates:
- serializedVersion: 1
m_State: {fileID: -99283565050525444}
m_Position: {x: 368, y: 210, z: 0}
m_Position: {x: 370, y: 110, z: 0}
- serializedVersion: 1
m_State: {fileID: 3137088567961274854}
m_Position: {x: 370, y: 270, z: 0}
m_ChildStateMachines: []
m_AnyStateTransitions: []
m_EntryTransitions: []

View File

@@ -29,7 +29,36 @@ ModelImporter:
animationWrapMode: 0
extraExposedTransformPaths: []
extraUserProperties: []
clipAnimations: []
clipAnimations:
- serializedVersion: 16
name: Death
takeName: mixamo.com
internalID: -203655887218126122
firstFrame: 0
lastFrame: 177
wrapMode: 0
orientationOffsetY: 0
level: 0
cycleOffset: 0
loop: 0
hasAdditiveReferencePose: 0
loopTime: 0
loopBlend: 0
loopBlendOrientation: 0
loopBlendPositionY: 0
loopBlendPositionXZ: 0
keepOriginalOrientation: 1
keepOriginalPositionY: 0
keepOriginalPositionXZ: 0
heightFromFeet: 1
mirror: 0
bodyMask: 01000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000
curves: []
events: []
transformMask: []
maskType: 3
maskSource: {instanceID: 0}
additiveReferencePoseFrame: 0
isReadable: 0
meshes:
lODScreenPercentages: []

View File

@@ -136,6 +136,15 @@ public partial class @GameInputAction: IInputActionCollection2, IDisposable
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
},
{
""name"": ""Reload"",
""type"": ""Button"",
""id"": ""7bd7b761-fbb1-426d-8c5c-a9e053597a89"",
""expectedControlType"": """",
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
}
],
""bindings"": [
@@ -237,6 +246,17 @@ public partial class @GameInputAction: IInputActionCollection2, IDisposable
""action"": ""ADS Camera"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""f7aa340a-d21d-48a8-81a9-d673d57059d8"",
""path"": ""<Keyboard>/r"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Reload"",
""isComposite"": false,
""isPartOfComposite"": false
}
]
}
@@ -250,6 +270,7 @@ public partial class @GameInputAction: IInputActionCollection2, IDisposable
m_Player_Jump = m_Player.FindAction("Jump", throwIfNotFound: true);
m_Player_Shoot = m_Player.FindAction("Shoot", throwIfNotFound: true);
m_Player_ADSCamera = m_Player.FindAction("ADS Camera", throwIfNotFound: true);
m_Player_Reload = m_Player.FindAction("Reload", throwIfNotFound: true);
}
~@GameInputAction()
@@ -335,6 +356,7 @@ public partial class @GameInputAction: IInputActionCollection2, IDisposable
private readonly InputAction m_Player_Jump;
private readonly InputAction m_Player_Shoot;
private readonly InputAction m_Player_ADSCamera;
private readonly InputAction m_Player_Reload;
/// <summary>
/// Provides access to input actions defined in input action map "Player".
/// </summary>
@@ -367,6 +389,10 @@ public partial class @GameInputAction: IInputActionCollection2, IDisposable
/// </summary>
public InputAction @ADSCamera => m_Wrapper.m_Player_ADSCamera;
/// <summary>
/// Provides access to the underlying input action "Player/Reload".
/// </summary>
public InputAction @Reload => m_Wrapper.m_Player_Reload;
/// <summary>
/// Provides access to the underlying input action map instance.
/// </summary>
public InputActionMap Get() { return m_Wrapper.m_Player; }
@@ -407,6 +433,9 @@ public partial class @GameInputAction: IInputActionCollection2, IDisposable
@ADSCamera.started += instance.OnADSCamera;
@ADSCamera.performed += instance.OnADSCamera;
@ADSCamera.canceled += instance.OnADSCamera;
@Reload.started += instance.OnReload;
@Reload.performed += instance.OnReload;
@Reload.canceled += instance.OnReload;
}
/// <summary>
@@ -433,6 +462,9 @@ public partial class @GameInputAction: IInputActionCollection2, IDisposable
@ADSCamera.started -= instance.OnADSCamera;
@ADSCamera.performed -= instance.OnADSCamera;
@ADSCamera.canceled -= instance.OnADSCamera;
@Reload.started -= instance.OnReload;
@Reload.performed -= instance.OnReload;
@Reload.canceled -= instance.OnReload;
}
/// <summary>
@@ -508,5 +540,12 @@ public partial class @GameInputAction: IInputActionCollection2, IDisposable
/// <seealso cref="UnityEngine.InputSystem.InputAction.performed" />
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
void OnADSCamera(InputAction.CallbackContext context);
/// <summary>
/// Method invoked when associated input action "Reload" is either <see cref="UnityEngine.InputSystem.InputAction.started" />, <see cref="UnityEngine.InputSystem.InputAction.performed" /> or <see cref="UnityEngine.InputSystem.InputAction.canceled" />.
/// </summary>
/// <seealso cref="UnityEngine.InputSystem.InputAction.started" />
/// <seealso cref="UnityEngine.InputSystem.InputAction.performed" />
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
void OnReload(InputAction.CallbackContext context);
}
}

View File

@@ -50,6 +50,15 @@
"processors": "",
"interactions": "",
"initialStateCheck": false
},
{
"name": "Reload",
"type": "Button",
"id": "7bd7b761-fbb1-426d-8c5c-a9e053597a89",
"expectedControlType": "",
"processors": "",
"interactions": "",
"initialStateCheck": false
}
],
"bindings": [
@@ -151,6 +160,17 @@
"action": "ADS Camera",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "f7aa340a-d21d-48a8-81a9-d673d57059d8",
"path": "<Keyboard>/r",
"interactions": "",
"processors": "",
"groups": "",
"action": "Reload",
"isComposite": false,
"isPartOfComposite": false
}
]
}

View File

@@ -9,6 +9,7 @@ namespace Darkmatter.Core
bool canAttack { get; }
string WeaponName { get; }
public int AmmoCount { get; }
public int maxAmmoCount { get; }
}
}

View File

@@ -7,6 +7,7 @@ namespace Darkmatter.Core
{
public event Action OnJumpPerformed;
public event Action OnAdsCameraSwitch;
public event Action OnReloadPerformed;
public Vector2 moveInput { get; }
public Vector2 lookInput { get; }
public bool isShooting { get; }

View File

@@ -11,6 +11,7 @@ namespace Darkmatter.Core
public event Action OnJumpPerformed;
public event Action OnAdsCameraSwitch;
public event Action OnReloadPerformed;
public bool isShooting { get; private set; }
public Vector2 moveInput { get; private set; }
public Vector2 lookInput { get; private set; }
@@ -62,5 +63,13 @@ namespace Darkmatter.Core
OnAdsCameraSwitch?.Invoke();
}
}
public void OnReload(InputAction.CallbackContext context)
{
if(context.performed)
{
OnReloadPerformed?.Invoke();
}
}
}
}

View File

@@ -12,6 +12,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d868e8202f5ceae4ea496e56b0db9db9, type: 3}
m_Name: PlayerConfigSO
m_EditorClassIdentifier: CoreAssembly::Darkmatter.Core.PlayerConfigSO
moveSpeed: 3
moveSpeed: 2
jumpForce: 5
gravity: -15

View File

@@ -14,6 +14,7 @@ namespace Darkmatter.Domain
public override void Enter()
{
Debug.Log("Entering Player AirboneState ");
inputReader.OnReloadPerformed += HandleManualReload;
}
public override void Update()
{
@@ -22,11 +23,6 @@ namespace Darkmatter.Domain
CheckForStateBreak();
}
private void HandleShoooting()
{
runner.Shoot(inputReader.isShooting);
}
public override void LateUpdate()
{
HandlePlayerRotation();
@@ -35,6 +31,7 @@ namespace Darkmatter.Domain
public override void Exit()
{
Debug.Log("Exiting Player AriboneState");
inputReader.OnReloadPerformed -= HandleManualReload;
}
@@ -56,5 +53,15 @@ namespace Darkmatter.Domain
runner.ChangeState(new LocomotionState(runner));
}
}
private void HandleShoooting()
{
runner.Shoot(inputReader.isShooting);
}
private void HandleManualReload()
{
runner.Reload();
}
}
}

View File

@@ -14,6 +14,7 @@ namespace Darkmatter.Domain
{
Debug.Log("Starting player Locomotion");
inputReader.OnJumpPerformed += HandlePlayerJump;
inputReader.OnReloadPerformed += HandleManualReload;
}
public override void Update()
@@ -24,10 +25,6 @@ namespace Darkmatter.Domain
}
private void HandleShooting()
{
runner.Shoot(inputReader.isShooting);
}
public override void LateUpdate()
{
@@ -38,6 +35,7 @@ namespace Darkmatter.Domain
{
Debug.Log("Exiting Player Locomotion State");
inputReader.OnJumpPerformed -= HandlePlayerJump;
inputReader.OnReloadPerformed -= HandleManualReload;
}
@@ -67,6 +65,17 @@ namespace Darkmatter.Domain
playerAnim.PlayJumpAnim();
}
private void HandleShooting()
{
runner.Shoot(inputReader.isShooting);
}
private void HandleManualReload()
{
runner.Reload();
}

View File

@@ -65,5 +65,13 @@ namespace Darkmatter.Domain
}
public void Reload()
{
if(GunWeapon.AmmoCount < GunWeapon.maxAmmoCount)
{
playerAnim.PlayReloadAnim(GunWeapon);
}
}
}
}

View File

@@ -9,9 +9,11 @@ namespace Darkmatter.Domain
public abstract string WeaponName {get; }
public abstract void Attack();
public virtual int AmmoCount { get; set; }
public virtual int AmmoCount { get; protected set; }
public int maxAmmoCount { get; private set; } = 40;
public abstract void Attack();
public virtual void Reload()
{

View File

@@ -26,19 +26,39 @@ namespace Darkmatter.Presentation
IEnumerator ReloadRoutine(IWeapon currentWeapon)
{
animator.SetLayerWeight(1, 1);
yield return BlendLayerWeight(1, 1, 0.2f);
//animator.SetLayerWeight(1,1);
HandOnGunIK.weight = 0f;
animator.SetTrigger(reloadHash);
yield return new WaitForSeconds(3f); //gave the length of the animation very bad practice
animator.SetLayerWeight(1, 0);
// animator.SetLayerWeight(1, 0);
yield return BlendLayerWeight(1, 0, 0.2f);
HandOnGunIK.weight = 1f;
currentWeapon.Reload();
reloadCoroutine = null;
}
IEnumerator BlendLayerWeight(int layerIndex, float targetWeight, float blendTime)
{
float startWeight = animator.GetLayerWeight(layerIndex);
float time = 0f;
while (time < blendTime)
{
time += Time.deltaTime;
float t = time / blendTime;
float weight = Mathf.Lerp(startWeight, targetWeight, t);
animator.SetLayerWeight(layerIndex, weight);
yield return null;
}
animator.SetLayerWeight(layerIndex, targetWeight);
}
public void PlayShootAnim()
{
Debug.Log("player Shoot");

View File

@@ -7,19 +7,24 @@ namespace Darkmatter.Presentation
{
public float health = 100f;
public Animator enemyAnimator;
public bool isDead = false;
public void Die()
{
isDead = true;
Debug.Log("Dead");
this.gameObject.SetActive(false);
enemyAnimator.SetLayerWeight(0, 1);
enemyAnimator.SetTrigger("Death");
Destroy(this.gameObject, 5f);
}
public void TakeDamage(float damage)
{
{ if(isDead) return;
health -= damage;
enemyAnimator.SetLayerWeight(1, 1);
enemyAnimator.SetTrigger("Hit");
if (health <= 0) Die();
Debug.Log("Damage Taken");
enemyAnimator.SetLayerWeight(1, 1);
enemyAnimator.SetTrigger("Hit");
}
}
}

View File

@@ -14,13 +14,14 @@ namespace Darkmatter.Presentation
[Header("Weapon Data")]
public float fireRate = 0.1f;
public override int AmmoCount { get; protected set; } = 40;
[SerializeField] private int ammoCount = 40;
private float lastUsedTime;
public GameObject BulletHole;
public override string WeaponName => "Rifel";
public override int AmmoCount { get => this.ammoCount; set => ammoCount = value; }
public override bool canAttack => Time.time >= lastUsedTime + fireRate && AmmoCount > 0;
public override bool canAttack => Time.time >= lastUsedTime + fireRate && ammoCount > 0;
[Inject] private ITargetProvider targetProvider;
private RaycastHit hitPoint => targetProvider.hitPoint;
@@ -30,7 +31,7 @@ namespace Darkmatter.Presentation
public override void Attack()
{
lastUsedTime = Time.time;
AmmoCount--;
ammoCount--;
PlayMuzzleFlash();
if (hitPoint.transform != null) PlayBulletHitEffectParticle();
@@ -61,7 +62,7 @@ namespace Darkmatter.Presentation
public override void Reload()
{
base.Reload();
AmmoCount = 40;
ammoCount = maxAmmoCount;
}
private void PlayMuzzleFlash()

File diff suppressed because it is too large Load Diff