GM Version: GameMaker Studio 2.3
Target Platform: All
Download: https://www.dropbox.com/s/h3sfhwc33gmucxy/FreeCamera.yyz
Links: N/A
Summary:
A video tutorial on how to freely rotate a 3D camera using the built-in matrix functions, plus some useful matrix knowledge.
Tutorial:
Matrix build and matrix multiply are two very useful functions, and learning how to use these will be invaluable if you intend to work with 3D in GM.
When it comes to rotating a camera, a lot of implementations make use of Euler angles/spherical coordinates for keeping track of camera orientation. This makes sense for games where there is a set up direction, like in most first-person shooters; when looking straight up in an FPS and then rotating to the side, the camera ends up spinning in place. This actually represents the loss of one axis of rotation, since both changing the yaw and the roll of the camera will result in the same transformation. This "locking" of one axis to another is what's called gimbal lock.
For other kinds of games, like flight simulators, gimbal lock is an undesired property. There's been a lot of confusion around how to avoid gimbal lock, and people often like suggesting using quaternions as the go-to solution. And while it's true, quaternions allow for gimbal lock-free rotations, they're not the only available solution; matrices will do the job just fine.
And since GM has basic matrix support built in, I would rather suggest this as the go-to solution.
Enjoy the video! Feedback is always appreciated!
Target Platform: All
Download: https://www.dropbox.com/s/h3sfhwc33gmucxy/FreeCamera.yyz
Links: N/A
Summary:
A video tutorial on how to freely rotate a 3D camera using the built-in matrix functions, plus some useful matrix knowledge.
Tutorial:
Matrix build and matrix multiply are two very useful functions, and learning how to use these will be invaluable if you intend to work with 3D in GM.
When it comes to rotating a camera, a lot of implementations make use of Euler angles/spherical coordinates for keeping track of camera orientation. This makes sense for games where there is a set up direction, like in most first-person shooters; when looking straight up in an FPS and then rotating to the side, the camera ends up spinning in place. This actually represents the loss of one axis of rotation, since both changing the yaw and the roll of the camera will result in the same transformation. This "locking" of one axis to another is what's called gimbal lock.
For other kinds of games, like flight simulators, gimbal lock is an undesired property. There's been a lot of confusion around how to avoid gimbal lock, and people often like suggesting using quaternions as the go-to solution. And while it's true, quaternions allow for gimbal lock-free rotations, they're not the only available solution; matrices will do the job just fine.
And since GM has basic matrix support built in, I would rather suggest this as the go-to solution.
Enjoy the video! Feedback is always appreciated!
Last edited: