首先设置骨骼类型 必须是人物骨骼
因为要和动作融合所以一定要设置
之后就可以看向了 一般用于 枪械游戏
Weight 全局权重,后面所有参数的系数
bodyWeight 身体权重,身体参与LookAt的程度,一般是0
headWeight 头部权重,头部参与LookAt的权重,一般是1
eyesWeight 眼睛权重,眼睛参与LookAt的权重,一般是0(一般没有眼睛部分的骨骼)
clampWeight 权重的限制。0代表没有限制(脖子可能看起来和断了一样),1代表完全限制(头几乎不会动,像是固定住了)。0.5代表可能范围的一半(180度)。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SetIk : MonoBehaviour
{
public Transform head;
public Animator animator;
private void OnAnimatorIK(int layerIndex) //设置动画 的层数
{
animator.SetLookAtWeight(1);
animator.SetLookAtPosition(head.position);
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}