I’m working on script which would allow me to move rigidbody to given targed position using forces. I’m planning to do it by building control system with PID controller in Matlab, find correct parameters there and then script it in Unity3d. But to do this I’d need to know transfer function, i.e. how exactly force and parameters like mass or drag influence the movement of my rigidbody. I believe that I can easily calculate such function if only applied force is to be considered. But drag is a problem to me, because I don’t know how exactly does it work. I’m not physicist, I have only some basic knowledge about it, so it’s quite difficult for me to understand drag in Unity3d. I’ve tried to test it against drag equations for small Reynolds numbers (F = -d*v) by giving my object constant velocity in Start() function and then adding following force in every FixedUpdate
GetComponent<Rigidbody> ().AddForce (GetComponent<Rigidbody> ().drag * GetComponent<Rigidbody>().velocity);
If Unity3d’s drag had followed mentioned equation, then object’s velocity would stay constant, as force opposing drag force would be applied all the time. And it worked perfectly for low values of drag (drag < 0) and mass equal to 1. But changing mass or drag parameter lead to changes in object’s velocity, so this equation was no longer correct.
Does anyone know how exaclty Unity3d’s drag parameter influence movement of rigidbody? Is there any kind of equation which I could use in my system?