added reload animation and feature
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user