super newb asks questions:
I was thinking about trying to figure out how to make a PID controller for my spaceship rotation stabilization.
presently I do not have any rotation stabilization as friction falls outside of the premise of my game.
However, a proper PID rotation stabilizer would be perfectly within!! (it would be terribly hard to use in certain circumstances, for example while fixed-jointed to a weight)
Upon my first attempt, and then some more searches, I found that rotation PID in unity is largely undesirable as it is quite a bit more work than translation stabilization given that there is “extra math” involved.
My question is, is this because of quaternions, or is it because rotating past 0 and 360 doesn’t work? a combination?? I know that when I make a simple camera script so that player input can aim the camera, the camera bonks into 0 points on at least one axis, and the player then needs to spin the camera to go back the other way or something like that. ((this one too, I would like to eliminate. I suppose I would need to make the camera go from 0 - 360 and from 360 - 0 with an if statement? ))
but elsewhere I saw that one problem is that the rotation is not stored in degrees, it’s stored in what, radians? Then the other issue gets to be that rotation is a local factor, while it is also a global factor, and this can be an issue, but I think with mine it is possible to simply have the one ship be within a single local gameobject, so perhaps not my issue.
bear in mind, it’s not as though my first attempt worked even a little. I did get SOMETHING happening, but I never got it to go the right direction. It seemed whether I used -pid or just pid, it always accelerated away from my setpoints rotation, rather than towards it , and then I definitely encounted the zero-point behavior of the rotation because sometimes it would actually bounce off of it. and just oscillate in that bounce.
I also saw some posters that did appear to be quite knowledgeable who still commented later that they had to stop using the physics engine and instead switch to setting the transform for rotation stabilization, which DID fundamentally change the rotation behavior. This is unfortunately out of the question with no exceptions. If i can’t use the physics engine basically, I will not pursue it at all. (I won’t really use it anyway, it’s just that I think it would be interesting to think about, I only play full manual thrust rotation. )
PIDs are probably not that easy without the unity specific issues, but I can find lots of information about that, I’m hoping with this question to understand which unity specific design issues I need to address to make it so that it just works as in the translation stabilization where although I did not try I am to understand in forum posts does work normally.