Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | VanKurt |
Hey there!
I would like to find out if an object in my scene points down. In my case this object a gun, that needs to be pointed at the floor to reload (it’s a VR game).
I tried the following piece of code:
var angle = get_global_transform().basis.get_euler().angle_to(Vector3.DOWN)
if(angle < 20):
reload()
My idea was t get the object’s global orientation vector and compare it to the world’s global DOWN vector. If the angle between both vectors iy smaller than 20 degrees, the gun must be pointing at the floor.
But actually this code does not what I thought it would do. It just returns a constant value, now matter how I rotate my object. Also I might have mixed up degrees and radians, bt that is a different problem
Can anyone give me ahint on how to get the global orientation vector of a node?