Automatic Placer

Chara

Member
I made an object that produces particles, and to make things simpler for myself I attempted to make an object that automatically places these emitters anywhere where there aren't walls
The code I'm using is as follows (in alarm 0):
GML:
if(!place_meeting(x,y,obj_wall)){instance_create(x,y,obj_floor)}
x+=20
if(x>room_width){y+=20;x=0}
if(y>room_height){instance_destroy(self)}
alarm[1]=1
The create event just sets the object's coordinates to be 0, 0 and activates alarm 0, alarm 1 only activates alarm 0. obj_floor is the emitter

After some testing I've determined that there must be something wrong with place_meeting, because it just places the emitter in every available space regardless of if an obj_wall is present there or not

Any idea what I'm doing wrong?
 

ophelius

Member
Are the wall objects maybe on a different layer than the floor objects? I'm pretty sure an object can only check for collision on objects of the same layer.
Apart from that, the code looks fine
 

Chara

Member
It's not really a fix, but I just made it so that the emitters delete themselves if they collide with an obj_wall

I still wonder what went wrong though... 🤔
 

Nidoking

Member
Does this object (the one you posted code from, not the obj_floor) have a sprite? Can't have collision without a bounding box.
 

ophelius

Member
OH
That makes sense, thank you, it did not have a sprite
If you don't need a sprite but need collision, just draw like a box for the sprite and turn off the 'visible' checkmark in the object's properties
 
Last edited:
Top