#Math help needed, How to turn a vector2 into rotation
1 messages · Page 1 of 1 (latest)
you would be able to just plug in mesh.rotation = Vector3(input.x,0,input.y) but that would make it pivot around the meshes center, not the bottom
i think to actually set a pivot point for 3d rotations you need to understand quaternions (not helpful) but you can kinda work around it
if you make the mesh a child of an empty node3d positioned around the base of the mesh, then you can rotate the node3d and have the mesh rotate around the node3d
I'm not sure how much code in your project is running in the mesh node itself but if it's just the rotation then you can move that to the node3d, if the input vector is being passed into the mesh then you can just pass it into the node3d instead
im not sure what the range of your input vector is, but angles in godot are measured in radians. so if the input vector went between -1.0 and 1.0 then you would want Node3D.rotation = Vector3(input_vec.x*(PI/2.0),0,input_vec.y*(PI/2.0)) for the rotation to range from -90 to 90 degrees
using this method still does the same math behind the scenes but is easier to impliment
but might be annoying if you want to minimize the ammount of nodes in your scene
i already tried that and it didnt give the desired result, but i ended up making a workaround by implementing the whole mechanic differently after trying like 50 things, thanks for the advice anyways