アニメーションにIKを付けて
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Mesen : MonoBehaviour
{
Animator animator;
Vector3 LookPos;
// Start is called before the first frame update
void Start()
{
//Animatorコンポーネントを取得
this.animator = GetComponent<Animator>();
//Mainカメラの方向を見るようにする準備
this.LookPos = Camera.main.transform.position;
}
// Update is called once per frame
void Update()
{
this.LookPos = Camera.main.transform.position;
}
private void OnAnimatorIK(int layerIndex)
{
//どの部位がどのくらい見るかを決める
this.animator.SetLookAtWeight(1.0f, 0.0f, 1.0f, 0.0f, 0f);
//どこを見るか(今回はカメラの位置)
this.animator.SetLookAtPosition(this.LookPos);
}
}