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: