- Home /
Question by
Ashmit2020 · Mar 24 at 05:57 AM ·
animation3d modelinverse kinematic
How to limit the rotation of a AI character which is using inverse kinematics?
how can I limit the rotation of a character? Right now, my character bends in a weird way when the player goes behind it. So, how can I stop that?
here's the code: using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Enemycont : MonoBehaviour
{
[SerializeField] Animator animator = null;
[SerializeField] Transform lookPos;
[SerializeField, Range(0f, 1f)] private float lookAtWeight = 1.0f;
[SerializeField, Range(0f, 1f)] private float bodyWt = .85f;
[SerializeField, Range(0f, 1f)] private float headWt = .9f;
[SerializeField, Range(0f, 1f)] private float eyesWt = .5f;
[SerializeField, Range(0f, 1f)] private float limitation = 0.0f;
private void OnAnimatorIK(int layerIndex)
{
animator.SetLookAtWeight(lookAtWeight, bodyWt, eyesWt, headWt, limitation);
animator.SetLookAtPosition(lookPos.position);
Debug.Log(lookPos.position);
}
}
Comment
Your answer
Follow this Question
Related Questions
How To Prevent 2D-IK Sprite Skin Rotation? 0 Answers
Reference for fps bow shooting? 2 Answers