aboutsummaryrefslogtreecommitdiff
path: root/scripts/utils.gd
diff options
context:
space:
mode:
authorjacopograndi <jacopo.grandi@outlook.it>2021-12-09 00:52:59 +0100
committerjacopograndi <jacopo.grandi@outlook.it>2021-12-09 00:52:59 +0100
commit0f518727c28d3204415db14c7ca0e4f7cb653677 (patch)
treea595121771b69a52f17154d8e5c61b7e4b2b8190 /scripts/utils.gd
working
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)