Godot Version
4.2.1-stable
Question
I’m trying to align a scene so that the Vector3(0,1,0) is redefined as a surface normal.
I have this code:
this_decal.global_transform.basis.y = normal
this_decal.global_transform.basis.x = -this_decal.global_transform.basis.z.cross(normal)
this_decal.global_transform.basis = this_decal.global_transform.basis.orthonormalized()
It causes weird distortions at some angles. The most noticeable one is if the normal is Vector3(0,0,1) or Vector3(0,0,-1). In those cases, the scale will be set to zero for some reason.
I should note that I am not a professional with transformation matrices. I only needed to take 1 semester of it in at university and they failed to cover practical applications of them.
How do I fix this? If I force set the scale to 1, the resulting decal is still not properly rotated.
The code was taken from this.
I’ve tried using look_at() but it also doesn’t produce the intended behavior.