In designing a mission editor I had to use multiple cameras (up to 3 active at one time, many more in total that get made/deleted as time advances). I noticed sometimes the main camera would move instead one of the other cameras. Here what the original code looked like:
dbMakeCamera(nb);
dbPositionCamera(nb, 0, 130, -130);
dbPointCamera(nb, 0, 0, 0);
dbSetCameraView(nb, viewport.x1, viewport.y1, viewport.x2, viewport.y2);
For some reason, sometimes some of the functions following dbMakeCamera would affect camera 1 instead of camera 3 (which is what nb was equal to). I modified the code to this :
dbMakeCamera(nb);
dbSetCurrentCamera(nb); // added this to set internal active camera in DarkSDK
dbPositionCamera(nb, 0, 130, -130);
dbPointCamera(nb, 0, 0, 0);
dbSetCameraView(nb, viewport.x1, viewport.y1, viewport.x2, viewport.y2);
and all of a sudden everything behaved as it should. In theory shouldn't both blocks of code produce exactly the same result?
I know the code I provide is not enough to reproduce the bug. The bug was very random and would happen after I created/deleted cameras a few times.
I'm just throwing this here to see if other people experienced similar behaviour when using multiple cameras, maybe give the devs something to look into and most of all give a workaround to people who might be having the same problem.
Thanks!
---
http://christianboutin.com