Tanoda
FastIKLook.cs
Go to the documentation of this file.
1using UnityEngine;
2
3namespace DitzelGames.FastIK
4{
5 public class FastIKLook : MonoBehaviour
6 {
10 public Transform Target;
11
15 protected Vector3 StartDirection;
16
20 protected Quaternion StartRotation;
21
22 void Awake()
23 {
24 if (Target == null)
25 return;
26
27 StartDirection = Target.position - transform.position;
28 StartRotation = transform.rotation;
29 }
30
31 void Update()
32 {
33 if (Target == null)
34 return;
35
36
37 transform.rotation = Quaternion.FromToRotation(StartDirection, Target.position - transform.position) * StartRotation;
38 }
39 }
40}
Vector3 StartDirection
Initial direction
Definition: FastIKLook.cs:15
Quaternion StartRotation
Initial Rotation
Definition: FastIKLook.cs:20
Transform Target
Look at target
Definition: FastIKLook.cs:10