added reload animation and feature

This commit is contained in:
Mausham
2025-12-30 16:22:49 -08:00
parent 1a61f3c506
commit 0ec69f66c9
16 changed files with 27895 additions and 26896 deletions

View File

@@ -1,15 +1,42 @@
using Darkmatter.Core;
using System;
using System.Collections;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.Animations.Rigging;
using VContainer;
namespace Darkmatter.Presentation
{
public class PlayerAnimController : HumonoidAnim, IPlayerAnim
{
private readonly int shootHash = Animator.StringToHash("IsShooting");
private readonly int reloadHash = Animator.StringToHash("Reload");
public TwoBoneIKConstraint HandOnGunIK; //for gunHand Ik
private Coroutine reloadCoroutine;
public void PlayReloadAnim()
public void PlayReloadAnim(IWeapon currentWeapon)
{
Debug.Log("Reloading");
if (reloadCoroutine == null)
{
reloadCoroutine = StartCoroutine(ReloadRoutine(currentWeapon));
}
}
IEnumerator ReloadRoutine(IWeapon currentWeapon)
{
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);
HandOnGunIK.weight = 1f;
currentWeapon.Reload();
reloadCoroutine = null;
}
public void PlayShootAnim()