Legacy GM limiting spawner area in a room

woods

Member
Code:
/// spawn pigs

if instance_number(obj_pig) < 5
{
    instance_create(random(room_width),random(room_height),obj_pig)
}
pretty straightforward.. but i have a house in the middle of the room and sometimes they spawn ontop of the building.. how do i limit the spawner to not spawn in this area?
main room boundary
x,y 0,0
xx,yy 2016,2016

house boundary
x,y 1068,896
xx,yy1440,1024


im not worried about the outside border as there is a outside room destroy()
 

Attachments

Gzebra

Member
Check if pig is within house boundary when it's created, if so, simply destroy it. (not the best approach)
 

woods

Member
for some reason i was thinking

if place_meeting(x,y,obj_block) {instance_destroy()}

wouoldnt work.. because if they walked into the side or top of the building.. they would destroy themselves..

point_in_rectangle in teh CREATE event works tho ;o) TYTY
 

Gzebra

Member
for some reason i was thinking

if place_meeting(x,y,obj_block) {instance_destroy()}

wouoldnt work.. because if they walked into the side or top of the building.. they would destroy themselves..

point_in_rectangle in teh CREATE event works tho ;o) TYTY
place_meeting might work as well, but the check should only be done in create event.
 
Top