public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { playerPos = GameObject.FindGameObjectWithTag("Player").transform; temperamentData = animator.GetComponent <TemperamentData>(); animationData = animator.GetComponent <AnimationData>(); aiSettingData = animator.GetComponent <AiSettingData>(); wayPointData = animator.GetComponent <WayPointData>(); attackRange = TemperamentManager.CombatTriggerRange(temperamentData.CombatStyle); moodRange = TemperamentManager.MoodTriggerRange(temperamentData.Mood); animatorOverrideController = new AnimatorOverrideController(animator.runtimeAnimatorController); //animatorOverrideController["Walking"] = animationData.AttackAnimation; clipOverrides = new AnimationClipOverrides(animatorOverrideController.overridesCount); animatorOverrideController.GetOverrides(clipOverrides); clipOverrides["Idle"] = animationData.IdleAnimation; clipOverrides["Walking"] = animationData.WalkAnimation; clipOverrides["Running"] = animationData.RunAnimation; clipOverrides["Attacking"] = animationData.AttackAnimation; clipOverrides["Death"] = animationData.DeathAnimation; animatorOverrideController.ApplyOverrides(clipOverrides); animator.runtimeAnimatorController = animatorOverrideController; }
public override void Run(MonoBehaviour reference) { WayPointData wayPointData = reference as WayPointData; wayPointDatas.Add(wayPointData); foreach (var wayPointref in wayPointDatas) { wayPointref.StartCoroutine(Move(wayPointref)); } }
private IEnumerator Move(WayPointData wayPointData) { yield return(new WaitForEndOfFrame()); float step = speed * Time.deltaTime; Vector3 newPosition = wayPointData.WayPoints[wayPointIndex].position; while (Vector3.Distance(wayPointData.gameObject.transform.position.ToZeroY(), newPosition.ToZeroY()) > 0.1f) { GameObject target = wayPointData.gameObject; //target.transform.position = Vector3.MoveTowards(target.transform.position, newPosition, speed); target.transform.LerpTransform(wayPointData, newPosition, step); } if (wayPointIndex < wayPointData.WayPoints.Count - 1) { wayPointIndex++; } else { wayPointIndex = 0; } StartCoroutine(Move(wayPointData)); }