D
Double7
Guest
Hey guys, getting used to GMS2 now and trying to figure out the camera system. The current effect I am going for is for the camera to rotate to a certain angle on command. However I am currently having an issue where the screen just goes black anytime I use camera_set_view_angle().
The video shows my issue
Here is an update on my findings after playing around in a different project for a bit.
1) calling camera_set_view_angle() on the default camera given by the engine will result in the proper effect
2) calling the function on a camera that was initialized with camera_create() and modified with camera_set_proj_mat() and camera_set_view_mat() will result in the screen turning black. (even if I copy the matrices directly from the default camera)
So this is leading me to believe that one of two things are leading to my issue. Which as usual is one of the following...
I'm stupid : I don't understand something set up within the default camera that allows the camera to avoid this issue. Which if applied to my created cameras would also fix this problem.
or
GM is stupid : Meaning camera_set_view_angle() only works with non-programmer created cameras
Seeing as most of the time I reach this conclusion it is the former that usually reveals to be the truth, I am going to keep digging into this. However the debugger doesn't seem to give too much info on cameras. Making this more difficult.
Ok, so I went through all of the possible gets and sets and figured out that setting the matrices for the camera does not set the variables view_height and view_width within the camera. You have to set these manually to ensure that they are not 0.
Hence a 0x0 view ported will be all black (or whatever background you have).
So if you want to rotate a camera you made, you need to make sure that you set these variables as well as the matrices.
EDIT:
So this fixes the problem if the cameras are not moving. If the cameras are moving then there are still issues where the screen either goes black or resets the angle every frame that the matrix is reset, even if I save and set the angle each time.
Going to sleep on this one I guess.
The video shows my issue
Here is an update on my findings after playing around in a different project for a bit.
1) calling camera_set_view_angle() on the default camera given by the engine will result in the proper effect
2) calling the function on a camera that was initialized with camera_create() and modified with camera_set_proj_mat() and camera_set_view_mat() will result in the screen turning black. (even if I copy the matrices directly from the default camera)
So this is leading me to believe that one of two things are leading to my issue. Which as usual is one of the following...
I'm stupid : I don't understand something set up within the default camera that allows the camera to avoid this issue. Which if applied to my created cameras would also fix this problem.
or
GM is stupid : Meaning camera_set_view_angle() only works with non-programmer created cameras
Seeing as most of the time I reach this conclusion it is the former that usually reveals to be the truth, I am going to keep digging into this. However the debugger doesn't seem to give too much info on cameras. Making this more difficult.
Ok, so I went through all of the possible gets and sets and figured out that setting the matrices for the camera does not set the variables view_height and view_width within the camera. You have to set these manually to ensure that they are not 0.
Hence a 0x0 view ported will be all black (or whatever background you have).
So if you want to rotate a camera you made, you need to make sure that you set these variables as well as the matrices.
EDIT:
So this fixes the problem if the cameras are not moving. If the cameras are moving then there are still issues where the screen either goes black or resets the angle every frame that the matrix is reset, even if I save and set the angle each time.
Going to sleep on this one I guess.
Last edited by a moderator: