- Home /
How can I rotate a vector direction around an arbitrary axis?
Hi! I'm working on a moon lander simulation, so I'm dealing with a spherical environment. What I'm trying to do is have the lander rotate toward the movement vector so that the lander starts to point down toward the moon as it gets higher in the air, but since the lander itself isn't orienting it's forward direction toward the movement vector, I have to rotate it's transform around an arbitrary axis. I don't want the rotation to be constant, I'd like to Slerp that movement between the aligned up rotation and the tilted up rotation based on height. I'm having a lot of trouble figuring out the tilted rotation.
Given that I have the rotation oriented to the horizon (with Up being (planet.position - lander.position).normalized , and the vector for the direction of movement, I'd like to find the forward and up vectors when they're rotated around 30 degrees along the right axis formed by Vector3.Cross( movementVector, up )
Is there some built in function I'm missing to do this?