Manual: Collision Detection and Raycast Settings

This section explains in detail how object wall collisions (CollisionShape2D) interact with tile walls and other object collisions in ACTION GAME MAKER, and how to configure them precisely.


Overview of Wall Collision and Raycast Behavior

In ACTION GAME MAKER, wall collision detection works by generating a rectangular collision area based on the size of the object’s CollisionShape2D.
From the four edges of this rectangle, rays—invisible detection lines used for normal-based collision checks—are emitted outward.

A Ray can be thought of as an invisible projectile fired at fixed intervals. When one of these rays touches another wall collider or tile, the system detects it as a collision.
This detection method is called Raycast.

Raycast Configuration

Raycast parameters can be adjusted in the conditions:

  • “Object Wall Collision”
  • “Tile Collision”
  • “Slope Tile Collision”

Number of Rays (ray_number)

This parameter is set as an integer and determines how many rays are emitted along each side of the detection area.
Rays are distributed evenly across the edge’s length.

For example, if one side is 24 pixels long:

  • With 3 rays, they’re placed every 12 pixels.
  • With 4 rays, they’re placed every 8 pixels.

A higher number of rays increases detection accuracy,
but also increases processing load—so be cautious with performance.


Detection Method (detect_method)

You can choose between Any and All:

  • Any: Collision is detected if at least one ray makes contact.
  • All: Collision is detected only if all rays make contact.

For example, when touching only at a corner:

  • Any → “Collision detected.”
  • All → “No collision detected.”

Ray Length (ray_length)

This is a float value that determines how far each ray travels (in pixels).
In other words, it defines how far away from the object a collision can still be detected.

This is especially important for objects that move vertically, such as elevators or lifts.
For example, when a lift moves down, the character’s position may temporarily separate from the platform for one frame.
If the ray length is too short, the system might momentarily think there is no contact.

However, if the ray length is too long, it can cause the system to detect collisions even when the objects are not actually touching.
A good rule of thumb is to adjust this based on:

  • The Snap Length value of GameObject > CharacterBody2D > Floor, or
  • The speed of the moving platform you are using.

Ray Offset (ray_offset)

This is a float value that defines how far from each corner the rays start.

As mentioned earlier, the collision detection area is always rectangular,
but actual colliders might be capsules, polygons, or multiple shapes.
Using offsets allows you to better match the rays to the real shape of your collider.

The offset value is measured in pixels from each end of an edge.
For instance, if one side is 24 pixels long and emits 3 rays, the layout looks like this:

Coordinate Space (coord_space)

This setting determines which coordinate space is used to interpret the direction of collisions.

It’s particularly useful when objects are rotated, as it changes how contact directions are evaluated.
For example:

  • If an object rotated 180° touches the floor, should it count as touching the bottom or the top?
  • If you want to detect a head hit, you might want it to count as “top.”
  • If you’re checking for ground contact, it should count as “bottom.”

There are also cases where only the collider rotates, not the whole object.

You can choose between three coordinate modes:
Global, Local is Game Object, and Local is Collision.
Let’s look at two examples:

① When the entire GameObject is rotated 45° and touches the ground:

② When only the collider is rotated 90°, while the GameObject remains unrotated:

  1. Global (Global coordinate space)
    Detection is based on the world coordinates of the GameObject and the target collider.
    Rotation is not considered, so both case ① and ② are detected as touching the bottom.
  2. Local is Game Object (Local space of the GameObject)
    Detection is based on the GameObject’s local rotation.
  • In case ①: detected as touching right and bottom.
  • In case ②: detected as touching bottom.
  1. Local is Collision (Local space of the collider itself)
    Detection is based on the rotation of the collider only.
  • In case ①: detected as touching right and bottom.
  • In case ②: detected as touching right.

This may seem like a complex concept at first,
but mastering these settings allows you to build precise and flexible collision behavior that matches your game’s unique mechanics.

1 Like