GM: instance place
From GMpedia.org Wiki
- The correct title of this article is instance_place(x,y,obj). It appears incorrectly here because of technical restrictions.
- The correct title of this article is instance_place(). It appears incorrectly here because of technical restrictions.
Arguments
x = Horizontal position of the point we're checking. y = Vertical position of the point we're checking. obj = The object we're checking if is there.
Limitations
none
Note: Please remove limitations and port them in the "Remarks" section at the end of the article.
The instance_place() function returns the id of the instance of an object (obj) at a particular position (x,y).
[edit] Explanation
Unlike instance_position() this function will tell you if there would be a collision with obj if the object that does the check was placed at position (X,Y). So the 'place' where the check is made is all the pixels in the sprite. If any of those overlap a pixel in the other sprite the function return true.
hereIsAWall = instance_place(x+speed,y,obj_impassable); if(speed>0 && hereIsAWall) { x=hereIsAWall.x-sprite_width; speed=0; } else if([[GM: speed<0|speed<0]] and hereIsAWall) { x=hereIsAWall.x+hereIsAWall.sprite_width; speed=0; }
[edit] See Also
This article was originally found at the Game Maker Knowledge Base, contributed by SpectreNectar.
See the talk page for details
See the talk page for details

