- Home /
Question by
ryoga · Dec 24, 2021 at 10:46 PM ·
scripting beginnerik
how to add a pole to this simple ik script??
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class IKTest : MonoBehaviour {
public Transform[] Bones;
public Transform Target;
public Transform Pole;
protected Quaternion TargetInitialRotation;
protected Quaternion EndInitialRotation;
// Use this for initialization
void Awake()
{
TargetInitialRotation = Target.rotation;
EndInitialRotation = transform.rotation;
}
// Update is called once per frame
void Update () {
var lastBone = Bones[Bones.Length - 1];
for (var i = Bones.Length - 1; i >= 0; i--)
{
Bones[i].rotation = Quaternion.FromToRotation(lastBone.position - Bones[i].position, Target.position - Bones[i].position) * Bones[i].rotation;
}
}
}
Comment
Your answer
Follow this Question
Related Questions
How can I make the head turn with the camera? 0 Answers
positioning ui buttons in a scrollview 1 Answer
Camera returns to starting position after playing animation 2 Answers
BoundBox not working after being attached to GameObject using script 0 Answers
Unity2D : How can i change animation by dragging finger left or right on screen? 0 Answers