애니메이션 파라미터는 애니메이터 컨트롤러에서 정의된 변수로서, 스크립트에서 접근하고 값을 할당할 수 있습니다. 이를 통해 스크립트는 상태 머신을 제어하거나 흐름에 영향을 줄 수 있습니다.
예를 들어, 파라미터의 값을 애니메이션 커브로 업데이트 하고, 스크립트에서 접근하면 음향 효과의 높이를 다양화하여 애니메이션의 일부로 보이게 할 수 있습니다. 이와 비슷하게, 스크립트는 메카님이 선택할 수 있는 파라미터 값을 설정할 수 있습니다. 예를 들어, 스크립트는 파라미터가 블렌드 트리를 제어하도록 설정할 수 있습니다.
기본 파라미터 값은 애니메이터 창의 우측 상단에서 선택할 수 있는 파라미터 영역에서 설정할 수 있습니다. 파라미터 값은 다음의 네 가지 기본 타입 중 하나여야 합니다.
파라미터는 Animator 클래스의 SetFloat, SetInteger, SetBool, SetTrigger 및 ResetTrigger 등의 함수를 사용하여 스크립트로 부터 값을 할당 받을 수 있습니다.
다음은 사용자 입력 값과 충돌 검사에 기반하여 파라미터를 수정하는 스크립트 예제입니다.
using UnityEngine;
using System.Collections;
public class SimplePlayer : MonoBehaviour {
Animator animator;
// Use this for initialization
void Start () {
animator = GetComponent<Animator>();
}
// Update is called once per frame
void Update () {
float h = Input.GetAxis("Horizontal");
float v = Input.GetAxis("Vertical");
bool fire = Input.GetButtonDown("Fire1");
animator.SetFloat("Forward",v);
animator.SetFloat("Strafe",h);
animator.SetBool("Fire", fire);
}
void OnCollisionEnter(Collision col) {
if (col.gameObject.CompareTag("Enemy"))
{
animator.SetTrigger("Die");
}
}
}
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.