Collision Checking

This section deals with the various methods to check for collisions in GameMaker: Studio.

When planning motions or deciding on certain actions, it is often important to see whether there are collisions with other objects at certain places within the game world, and often choosing the right collision for the job is the most important task of all. GameMaker: Studio has a number of built in functions to help you deal with collisions correctly and in accordance with the needs of your project.

Simple Collision Checking

The following functions deal with the various ways in which you can have an instance check for collisions with another instance:

  1. place_empty
  2. place_free
  3. place_meeting
  4. position_empty
  5. position_meeting
  6. position_change
  7. position_destroy

Advanced Collision Checking

The following routines can be used for this (as well as other functions detailed in the sections relating to Moving Around and Instances). These collision functions all work slightly differently but they maintain three common arguments which we will explain here:

All these functions return either the id of an instance found to be colliding, or the special keyword noone when there is no collision. Note that if there are multiple collisions with the areas defined by these functions and instances of the given object, only one instance ID is returned, and it can be any one of the instances in the collision.

The following functions exist that deal with advanced collisions.

  1. collision_circle
  2. collision_ellipse
  3. collision_line
  4. collision_point
  5. collision_rectangle

Collision Checking Without Masks

All of the above functions are related to collision checking instances, and as such rely on the collision mask that is defined for the instance. However, there are many moments when you require to check for "collisions" with a point or an area, especially when your instance does not have a sprite assigned, or when you are working with the mouse etc... Therefore GameMaker: Studio also provides the following functions to help you in these situations:

  1. point_in_rectangle
  2. point_in_triangle
  3. point_in_circle
  4. rectangle_in_rectangle
  5. rectangle_in_triangle
  6. rectangle_in_circle


Back: Movement and Collisions
© Copyright YoYo Games Ltd. 2018 All Rights Reserved