3D [Solved] Activating Instances that can be seen by the Camera

S

Sylveax

Guest
Hi everyone. Nice too see that the GMC is back. Now to my problem:
I'm trying to deactivate all instances of a certain object that aren't inside the area visible to the camera (the players field of view). Everything I could think of was the point_in_triangle function, like this:

Code:
STEP EVENT
if point_in_triangle(x,y,obj_player.x,obj_player.y,obj_player.x+lengthdir_x(1000,obj_player.direction+40),obj_player.y + lengthdir_y(1000,obj_player.direction+40),obj_player.x+lengthdir_x(1000,obj_player.direction-40),obj_player.y + lengthdir_y(1000,obj_player.direction-40)) {
instance_deactivate_region(x,y,0,0,1,false)
} else {
instance_activate_region(x,y,0,0,1)
}

the 40 is there because the players FOV is set to 80 with d3d_set_projection_ext.

the only problem with that is the fact that I can't reactivate the instances once they're deactivated, because of course they don't run their step event code. I've searched google, the marketplace, reddit, the manual, the GMC, literally anything I could think of, for a solution. Didn't find even a single, remotely related result. Does anyone of you have an Idea? I would be extremely thankful!​
 
Last edited by a moderator:
Hi everyone. Nice too see that the GMC is back. Now to my problem:
I'm trying to deactivate all instances of a certain object that aren't inside the area visible to the camera (the players field of view). Everything I could think of was the point_in_triangle function, like this:

Code:
STEP EVENT
if point_in_triangle(x,y,obj_player.x,obj_player.y,obj_player.x+lengthdir_x(1000,obj_player.direction+40),obj_player.y + lengthdir_y(1000,obj_player.direction+40),obj_player.x+lengthdir_x(1000,obj_player.direction-40),obj_player.y + lengthdir_y(1000,obj_player.direction-40)) {
instance_deactivate_region(x,y,0,0,1,false)
} else {
instance_activate_region(x,y,0,0,1)
}

the 40 is there because the players FOV is set to 80 with d3d_set_projection_ext.

the only problem with that is the fact that I can't reactivate the instances once they're deactivated, because of course they don't run their step event code. I've searched google, the marketplace, reddit, the manual, the GMC, literally anything I could think of, for a solution. Didn't find even a single, remotely related result. Does anyone of you have an Idea? I would be extremely thankful!​
So there is a more complicated way to do this that I couldn't get to work but here is a vary easy way to do it:
Code:
instance_deactivate_object(obj_enemy)
instance_activate_region(view_xview[0],view_yview[0],view_wview[0],view_hview[0],1)
Execute this in the step event of a control object (an object that never gets deactivated) and it will deactivate all of the obj_enemy objects in the room then reactivate all of them in the view area. If you don't want the objects to get reactivated inside the view area then just change the coordinates in the command. Now for the problem with this code, if you have any other objects in the room that are deactivated and are in the view area then this code will reactivate it. If you don't want that to happen then your going to have to find another way to do this. Hope I helped ;)
 
S

Sylveax

Guest
So there is a more complicated way to do this that I couldn't get to work but here is a vary easy way to do it.
I know that, and it's great for 2d. My problem is, however, that I want to achieve that in 3d. That only the instances of obj_enemy that can be seen by the camera (ego-perspective of player) are active. For that it would need to check for a triangular region in which to activate instances, or maybe there's a completely different solution.
 
S

Sylveax

Guest
I didn't find a way to deactivate the instances, but I found a workaround that's working for me. It's still using the point_in_triangle function, but instead of activating or deactivating instances, it draws or doesn't draw them, depending on wheter they're in the triangle or not. Marking the thread as solved.
 
Top