using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; using KairoEngine.Core; namespace KairoEngine.CharacterSystem { /// /// Action to turn a character towards a point. /// public class CharacterTurnToPointAction : IAction { CharacterController character; // Reference to the character that will move Vector3 point; // Where to turn // Constructor public CharacterTurnToPointAction(CharacterController character, Vector3 point) { this.character = character; this.point = point; this.point.y = 0f; } public void Start() { Quaternion targetRotation = Quaternion.LookRotation (point - character.transform.position); character.animator.transform.rotation = Quaternion.Slerp (character.animator.transform.rotation, targetRotation, 100f * Time.deltaTime); } public void Update() { Quaternion targetRotation = Quaternion.LookRotation (point - character.transform.position); character.animator.transform.rotation = Quaternion.Slerp (character.animator.transform.rotation, targetRotation, 100f * Time.deltaTime); } public void End() { } public bool IsDone() { return true; } } }