123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using RootMotion.FinalIK;
- using RootMotion.Demos;
- using KairoEngine.Core;
- using KairoEngine.Inventory;
- namespace KairoEngine.CharacterSystem
- {
- public class SetAimIK : MonoBehaviour
- {
- public Transform weaponAimIK;
- public CharacterController character;
- public AimController aimController;
- public AimIK aimIK;
- public LimbIK limbIK;
- public SecondHandOnGun secondHandOnGun;
- private bool isRealoding = false;
- void OnEnable()
- {
- GenericEvents.StartListening(character.unique_name + "-Reloading", Reloading);
- GenericEvents.StartListening(character.unique_name + "-ReloadDone", ReloadDone);
- }
- void OnDisable()
- {
- GenericEvents.StopListening(character.unique_name + "-Reloading", Reloading);
- GenericEvents.StopListening(character.unique_name + "-ReloadDone", ReloadDone);
- }
- void Update()
- {
- if(weaponAimIK == null)
- {
- if(character.HasEquipedItem() && isRealoding == false)
- {
- if(character.GetEquipedItem().item.category == ItemType.firearm)
- {
- Firearm firearm = character.GetEquipedGameObject().GetComponent<Firearm>();
- weaponAimIK = firearm.aim;
- aimIK.solver.transform = weaponAimIK;
- limbIK.solver.target = firearm.grip;
- aimIK.enabled = true;
- limbIK.enabled = true;
- return;
- }
-
- }
- aimIK.enabled = false;
- limbIK.enabled = false;
- }
- }
- private void Reloading()
- {
- //Debug.Log("Reloading");
- isRealoding = true;
- weaponAimIK = null;
- secondHandOnGun.enabled = false;
- }
- private void ReloadDone()
- {
- //Debug.Log("Reloading Done");
- isRealoding = false;
- if(secondHandOnGun == null) return;
- secondHandOnGun.enabled = true;
- }
- }
- }
|