I’ve been messing with this bit of code for a while now but am still struggling to get it working, so I’m opening the discussion up

So I have a Satellite that can spin itself based on a Reaction Control System. Basically all I’m doing is applying Torque to the object when I want it to spin, and using a Particle system to make it look like the thrusters are doing it. See here:

The Thrusters (well, Torque) has a ‘Strength’ constant of 0.25. So 0.25 units of torque are added to the object per-second when I apply thrust in a given direction.

What I now need to do, is use the Torque / Thrusters to force the satellite to line-up with a certain rotation. What I’m doing is trying to line up the Actors’ forward vector with an arbitrary direction vector. I thought I’d done the Maths properly but it turns out that when you’re working with angles, it actually gets a lot more difficult.

I already have the code worked out for making the craft apply torque to reach the direction, but of course, it applies torque constantly until it gets there, then immediately overshoots it, and swings back the other way. This goes on forever unless I stop it by adding Angular damping, but of course in space there is no such thing and I need to simulate it properly by firing the thrusters the opposite way, so that it slows down just in time to stop spinning and end up facing the right way. I think I’ve worked out the basics of how to achieve this, but it doesn’t seem to be working or I’m just not implementing it correctly. Either way, I could use some more brains on this. Incoming whiteboard pic:

Hmmm, why are you locked into 25 Torque thrust? Is it like a fixed impulse you can apply?
What you could do is initiate your turn with a series of thrusts in a discrete time step. For example each second:
t1 - torque is 25, calculate your angular acceleration and velocity, knowing velocity calculate at what time you will reach desired angle
t2 - another 25 torque, recalculate your angular acceleration and velocity and time when you reach desired angle. If time to reach desired angle is acceptable from aesthetics point of view. Calculate when exactly you should initiate your last 25 torque thrust (which should be one time step before you reach target) and initiate another thrust just one time step before that.
So you would have equal amount of acceleration deceleration thrusts and the only unknown would be the time in between them. I would suggest removing angular damping as you could cut rotation yourself when it’s smaller than some delta.

We’re locked to 25 as a solid thrust because (n reality) the jets are either on or off, there’s no ‘Throttle’ as such, and the player has no throttle control either. However, the player does have the options to ‘customize’ the craft and change the strength of the jets, so that value isn’t really a constant that can be ‘tuned’, it all needs to be based off of that.

There is also NO angular damping right now, all damping is set to zero. The Satellite slows down using the Thrusters like it would in reality, by applying opposite force until it no longer needs to. That part is fairly easy, the difficult is knowing how long it should apply forces for if it wants to reach a given rotation. Additionally, the satellite still needs to be able to have any ‘Roll’ around the axis it’s supposed to be facing, so the idea is to use only pitch and yaw to match that direction. I already have the functionality in place to work out the difference, or the pitch and Yaw dot’s respectively, but the difficulty now is using the Angular Velocity and Acceleration to work out which way it should apply torque, and when to start and stop.

I found this online which in reading seems to be close to what I want to do, so far it doesn’t work as well though.