Я добавил переход между Walk и Idle и добавил новый параметр с именем Idle type bool.При переходе я установил значение «Время выхода» на «ложь», а затем в «Условиях» я добавил параметр «Ожидание», установив его значение «ложь».

Но при запускеВ игре переход работает даже в том случае, если для параметра Idle установлено значение false.
Я хочу, чтобы в моем сценарии при определенных условиях переход начался между Walk и Idle.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AnimatorController : MonoBehaviour
{
public Animator[] animators;
public Transform target;
public float speed = 1f;
public float rotationSpeed;
public bool slowDown = false;
private bool endRot = false;
private Vector3 center;
// Use this for initialization
void Start()
{
center = target.GetComponent<Renderer>().bounds.center;
for (int i = 0; i < animators.Length; i++)
{
animators[i].SetFloat("Walking Speed", speed);
}
}
// Update is called once per frame
void Update()
{
float distanceFromTarget = Vector3.Distance(animators[2].transform.position, target.position);
for(int i = 0; i < animators.Length; i++)
{
animators[2].transform.position = Vector3.MoveTowards(animators[2].transform.position, center, 0);
}
if (slowDown)
{
if (distanceFromTarget < 10)
{
float speed = (distanceFromTarget / 10) / 1;
for (int i = 0; i < animators.Length; i++)
{
animators[i].SetFloat("Walking Speed", speed);
}
}
}
if (distanceFromTarget < 3.5f)
{
for (int i = 0; i < animators.Length; i++)
{
animators[i].SetFloat("Walking Speed", 0);
}
if (!endRot)
{
Quaternion goalRotation = Quaternion.Euler(0f, 180f, 0f);
float angleToGoal = Quaternion.Angle(
goalRotation,
animators[0].transform.localRotation);
float angleThisFrame = Mathf.Min(angleToGoal, rotationSpeed * Time.deltaTime);
// use axis of Vector3.down to keep angles positive for ease of use
animators[0].transform.Rotate(Vector3.up, angleThisFrame);
animators[1].transform.Rotate(Vector3.down, angleThisFrame);
// We end if we rotated the remaining amount.
endRot = (angleThisFrame == angleToGoal);
}
}
}
}
Я хочу, чтобы вместо этого здесь останавливался объект:
if (distanceFromTarget < 3.5f)
{
for (int i = 0; i < animators.Length; i++)
{
animators[i].SetFloat("Walking Speed", 0);
}
Для медленного плавного переключения между ходьбой и холостым ходом.Переход работает нормально в редакторе, но я хочу, чтобы он запускался только тогда, когда расстояние меньше 3,5, а теперь при запуске игры переход начинается намного быстрее.