animator.SetLayerWeight(1, 1);
@ 사용 예시
using UnityEngine;
public class CharacterAnimationController : MonoBehaviour
{
private Animator animator;
void Start()
{
animator = GetComponent<Animator>();
// 처음에는 상체 애니메이션을 사용하지 않도록 상체 레이어의 가중치를 0으로 설정
animator.SetLayerWeight(1, 0f); // "UpperBody Layer"의 인덱스가 1이라고 가정
}
void Update()
{
// 왼쪽 마우스 버튼을 누르면 상체 애니메이션 레이어 가중치를 1로 설정 (상체 애니메이션 적용)
if (Input.GetMouseButtonDown(0))
{
animator.SetLayerWeight(1, 1f); // 상체 레이어의 가중치를 1로 설정
animator.SetTrigger("Shoot"); // 발사 애니메이션 재생
}
// 마우스 버튼을 떼면 상체 애니메이션 레이어 가중치를 다시 0으로 설정 (상체 애니메이션 미적용)
if (Input.GetMouseButtonUp(0))
{
animator.SetLayerWeight(1, 0f); // 상체 레이어의 가중치를 0으로 설정
}
}
}