123456789101112131415161718192021222324252627282930313233343536373839 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using KairoEngine.Core;
- namespace KairoEngine.CharacterSystem
- {
- public class CharacterMoveToPositionCommand : ICommand
- {
- CharacterController character;
- Vector3 targetPosition;
- float speed;
- float animationSpeed;
- float stoppingDistance;
- public CharacterMoveToPositionCommand(CharacterController character, Vector3 targetPosition, float speed, float animationSpeed = 1f, float stoppingDistance = 1f)
- {
- this.character = character;
- this.targetPosition = targetPosition;
- this.speed = speed;
- this.animationSpeed = animationSpeed;
- this.stoppingDistance = stoppingDistance;
- }
- public void Execute()
- {
- CharacterMoveToPositionAction action = new CharacterMoveToPositionAction(character, targetPosition, speed, animationSpeed, stoppingDistance);
- ActionController actionController = character.GetComponent<ActionController>();
- if(actionController.HasAction(action) == false)
- {
- actionController.AddAction(action);
- }
- else
- {
- actionController.ChangeAction(action);
- }
- }
- }
- }
|