• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - Code [Solved] Depth issue when using camera

Y

yearspassing

Guest
So this is a bit weird.
I created a new project and didn't write any code. I just created an object that creates a simple effect when I press a button.
effect_create_above(ef_explosion, 400, 400, 2, c_red);

Simple enough?

Then I add a camera. I follow the docs and I write this.

Code:
viewmat = matrix_build_lookat(640, 240, -10, 640, 240, 0, 0, 1, 0);
projmat = matrix_build_projection_ortho(640, 480, 1.0, 32000.0);
camera_set_view_mat(view_camera[0], viewmat);
camera_set_proj_mat(view_camera[0], projmat);
Then I use the same object and the explosion doesn't happen. If I change the code to effect_create_below(), the effect is being drawn.

As if the camera code somehow messed up with the depth system.

To further test this stuff I've created two objects (not simultaneously ofc hence the same coords):
Code:
instance_create_depth(400, 400, -10, Pigeon);
instance_create_depth(400, 400,  10, Pigeon);
The first one with the negative depth doesn't show and the second one shows fine.

Im completely lost.
 
Y

yearspassing

Guest
Oh yeah, got it.

Code:
viewmat = matrix_build_lookat(640, 240, -10, 640, 240, 0, 0, 1, 0);
The -10 is the camera position above the scene, I need it to be higher. -20000 seems to work fine.
 
Top