12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- 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<AimController>();
- 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;
- }
- }
- }
|