using System.Collections; using System.Collections.Generic; using UnityEngine; using RootMotion.FinalIK; using KairoEngine.Core; namespace KairoEngine.CharacterSystem { public class CharacterAimAction : IAction { CharacterController character; Transform target; AimController aimController; GameObject aimTarget; // Constructor public CharacterAimAction(CharacterController character, Transform target) { this.character = character; this.target = target; } public void Start() { aimController = character.GetComponentInChildren(); if(aimController != null) { if(aimController.target != null) { aimTarget = aimController.target.gameObject; } else { aimTarget = new GameObject(character.unique_name + "_AimTarget"); aimController.target = aimTarget.transform; } } else { End(); } aimTarget.transform.position = new Vector3(target.position.x, target.position.y + 1.4f, target.position.z); } public void Update() { aimTarget.transform.position = new Vector3(target.position.x, target.position.y + 1.4f, target.position.z); } public void End() { if(aimController != null) { aimController.target = null; } target = null; GameObject.Destroy(aimTarget); } public bool IsDone() { if(target == null) return true; else return false; } } }