# How can i set a node's rotation if i know the up vector and the forward angle

4.2.1

### Question

so i have this 3d object and i want to be able to manually set it’s ‘up vector’ and the angle around that vector that it is facing. i’ve been trying combinations of setting basis axes and multiplying transforms and i can’t figure it out. if i know the vector that should be ‘up’ and i have a scalar to keep track of the angle around that vector that ‘forward’ is, how can i set the rotation with these two quantities without resetting the position?

I’ve done his a few times in 2D but I’m not sure the code would translate perfectly as I’ve used Vector2. Are you using Vector3?

choppa_angle = Vector2(velocity.x, velocity.y).angle()
if velocity.length() > 0:

yes i have a 3d vector that i want to be ‘up’ and i have a float for how to rotate it around that up axis

1 Like

so do you know how to do this in 3D? this 2D example isn’t the answer

Sadly no. I was hoping my work in 2D would be helpful or point you in the right direction.

ah, no. unfortunately 3D rotation is a four dimensional problem, while 2D rotation is a one dimensional problem. i do actually know how i want my object to be rotated hence the vector and scalar, i just literally don’t know what the syntax is in gdscript

I’d suggest creating a new topic with a more specific title - something like “how to set angle using Vector3” so that people with more 3D experience than me will join in.

it says 3d immediately in the question

Does look_at work for you? The rotate function allows you to define a vector around which to rotate by an amount. I am having a hard time visualizing what constraints you are facing. What is your end goal here?

1 Like

True, but I’d suggest putting that in the title and the topic subjects.

oh that might work! i imagine look_at defaults to setting the forward vector, is there a way for me to set the up vector?

Yup, it’s the second argument!

that worked, thanks!