To answer it shortly, there is no “shortest angle between 2 vectors” whatever the angle between them is, that’s the angle, it’ll never change. iirc, you can just do the dot product of the 2 vectors, and if it’s positive, multiply by 90. if it’s negative take the absolute value of it, multiply by 90, and then add 90, and that’ll get you the angle between 2 vectors.
I want to get the velocity of an actor, get it’s current rotation, then find the shortest angle between them. I want to then turn this actor by angular impulse towards the direction of it’s velocity by the shortest path.
So direction of velocity, add impulse in direction of shortest path from it’s current forward vector to the vector of its velocity.
Key being I want to do it by adding angular impulse, not by rinterp or such.
Ok let me rephrase it. How can I get a vector which I can plug into the angular impulse that will take the shortest path towards the desired vector?
If I’m understanding you correctly, you just need to get the difference in rotation of the forward vector, and the velocity, then convert that from a rotation to a vector, and that should give you your vector you need. What is this for, if you don’t mind me asking? There might be a better way then adding impulse depending on what it is.
It’s for the controls for a spaceship. I already used add angular impulse for a button to stop the rotation of the ship by getting the normalized angular velocity and then multiplying it by the force I want the “thrusters” on the ship to have. The reason I wanted to use angular impulse for this turning to a preset angle control as well is I’d like to be able to use one value per ship for the thrusters where it would always turn with a set amount of acceleration. The method I did for angular impulse to stop spinning seems to work perfectly. I guess I could just use rinterp for the turning to a preset location and just manually adjust speed until it seems similar. But also I want the speed to be dependent on the angular velocity of the ship currently.
So basically what I’m trying to do for the control my question is about: I want to know the direction of velocity. I’m going to multipy by that by -1 to get the inverse direction of the velocity and then have the ship rotate to that angle with the press of a button for it to use its main thruster to point in the opposite direction from it’s velocity for a “flip and burn.” But like I said I’m trying to keep it physics based because I want consistent thruster turning power so it will move differently dependent on it’s current angular velocity and etc.
Think I didn’t reply in the right box. See below.
You should be able to use the code I sent to figure out the angle, then just use the code you have for stopping the ship for rotating to that point. You’d probably just have to mess around with the numbers to get the values correct