Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | mydoghasworms | |
Old Version | Published before Godot 3 was released. |
I am trying to read up on Quaternions and Transforms etc., but none of it make sense to me because I lack the necessary background.
I have a Body which I am moving around a maze, so it only moves along the X and Z axis and rotates around the Y, so I am just trying to determine the angle around the Y axis after having rotated. Using get_rotation() gives you a Vector3 which does not give the values as you’d expect. I’m think I am basically facing the same challenge as this person here: https://forum.godotengine.org/3457/what-is-even-going-on-with-3d-rotation
Any suggestions?
I always point people to this post, with movement and rotation basics that include the use of Quat, try to see if helps to understand a bit http://codetuto.com/2016/01/godot-engine-movement-and-rotation-basics/
eons | 2017-01-05 02:57
Thanks @eons. I did in fact go through that post and used a snippet of code from there to rotate an object without actually understanding what it does. I think I lack the mathematical background and probably need to get some education from other sources. I still don’t understand what a Quat is. Thanks anyway.
mydoghasworms | 2017-01-05 05:51
Someone suggested the following code on Discord, but it does not work, as the basis member is a Matrix3, so .x and .z are Vector3:
var thing_basis = get_node('Spatial').get_global_transform().basis
var angle = Vector2(basis.x, basis.z).angle()
When I saw it, at first I was very hopeful…
mydoghasworms | 2017-01-05 06:08
Well, if you want to work on 3D you will have to understand the weird things it has ^_^;
About the transform matrix first and how to use quaternions in case you can’t work with the transform matrix.
Also, I tend to forget, now Vector3 has angle_to, if what you want is to know how is your local front (basis.z) rotated respect to world z, do get_transform().basis.z.angle_to(Vector3(0,0,1))
Do some tests in a separate scene and check if is what you want playing with a TestCube.
eons | 2017-01-05 11:59