GML Visual How to get objects to react if in viewport?

Y

YeetNade

Guest
Hey everone, I have a problem. I've made a game with different levels, in one level you're on a fleet and zombies fall from trees on to the fleet.
The problem is that the zombies fall in the water before the fleet reaches them. Therefore I thought I could create an instance if the viewport hit something or give the zombiesa creation code that says if in the viewport start moving or something.
But the thing is I don't know how to do that. pls help?
 
S

Slothagami

Guest
I think this is what your looking for:
Code:
bar 
view = view_camera[0],
view_width = camera_get_view_width(view),
view_height = camera_get_view_height(view),
view_x = camera_get_view_x(view),
view_y = camera_get_view_y(view);

if x > view_x and x < view_x + view_width {
    if y > view_y and y < view_y + view_height {
        // Do things
    }
}
If you are using gamemaker 1.4 you would need to change some of the functions to view_wview and view_xview, etc

Good luck with your game!
 
Y

YeetNade

Guest
Ok! It's a little hard for me to understand what the code is because im 11 and I've only used D&N so far, but i think i understand the code. thanks! I'm gonna try it now!
 

Sabnock

Member
Ok! It's a little hard for me to understand what the code is because im 11 and I've only used D&N so far, but i think i understand the code. thanks! I'm gonna try it now!
11? All hail the future of gaming :). Good luck YeetNade and reach out if you need help with anything.
 
Top