Мои Уведомления
Привет, !
Мой Аккаунт Мои Финансы Мои Подписки Мои Настройки Выход
Руководство API скрипты

Объявление

public void SetBool(string name, bool value);

public void SetBool(int id, bool value);

Параметры

name Имя параметра.
id Идентификатор параметра.
value Новое значение параметра.

Описание

Устанавливает значение данного логического параметра.

Используйте Animator.SetBool для передачи логических значений контроллеру анимации. через скрипт.

Используйте это для запуска переходов между состояниями Animator. Например, запустить анимацию смерти, установив для логического значения «живой» значение false. Дополнительную информацию о настройке аниматоров см. в документации по Animation.

Примечание. Вы можете идентифицировать параметр по имени или идентификационному номеру, но имя или идентификационный номер должны совпадать с параметром, который вы хотите изменить в Animator.

//Set up a new Boolean parameter in the Unity Animator and name it, in this case “Jump”. //Set up transitions between each state that the animation could follow. For example, the player could be running or idle before they jump, so both would need transitions into the animation. //If the “Jump” boolean is set to true at any point, the m_Animator plays the animation. However, if it is ever set to false, the animation would return to the appropriate state (“Idle”). //This script enables and disables this boolean in this case by listening for the mouse click or a tap of the screen. using UnityEngine; public class Example : MonoBehaviour { //Fetch the AnimatorAnimator m_Animator; // Use this for deciding if the GameObject can jump or not bool m_Jump; void Start() { //This gets the Animator, which should be attached to the GameObject you are intending to animate. m_Animator = gameObject.GetComponent<Animator>(); // The GameObject cannot jump m_Jump = false; } void Update() { //Click the mouse or tap the screen to change the animation if (Input.GetMouseButtonDown(0)) m_Jump = true; //Otherwise the GameObject cannot jump. else m_Jump = false; //If the GameObject is not jumping, send that the Boolean “Jump” is false to the Animator. The jump animation does not play. if (m_Jump == false) m_Animator.SetBool("Jump", false); //The GameObject is jumping, so send the Boolean as enabled to the Animator. The jump animation plays. if (m_Jump == true) m_Animator.SetBool("Jump", true); } }
Вы можете отблагодарить автора, за перевод документации на русский язык. ₽ Спасибо
API скрипты 2021.3