aboutsummaryrefslogtreecommitdiff
path: root/scripts/utils.gd
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/utils.gd')
-rw-r--r--scripts/utils.gd10
1 files changed, 10 insertions, 0 deletions
diff --git a/scripts/utils.gd b/scripts/utils.gd
new file mode 100644
index 0000000..a0ecae4
--- /dev/null
+++ b/scripts/utils.gd
@@ -0,0 +1,10 @@
+class_name Utils
+extends Object
+
+static func quat_look (target, up):
+ var dot = target.dot(up)
+ var angle = acos(dot)
+ var axis = up.cross(target).normalized()
+ if angle == 0: axis = up
+ if angle == PI: axis = Vector3.RIGHT
+ return Quat(axis, angle)