Loading...

Logo
DocumentationBehaviorsObjectRaycast Test
Object

Raycast Test

Last updated May 2, 2023

Description

The Raycast Test behavior shoots an imaginary invisible ray from a starting point (origin) to a destination point and check if any objects intersect in that ray. Rays only intersect with non-scenery objects.

Properties

Triggers Once on Event

Raycast Type
  • Closest Object - Only the first object that the ray intersects will be included as an entry.
  • All Objects - Every object that the ray intersects will be included in the result. The outputs will be an array containing each entry.
    When this type is selected, the object, x_pos, y_pos, distance and normal output fields will be an array.
Layer

The ray will only intersect with objects in a layer you have selected. You have an option to unrestrict the ray to all layers.

Intersect With

The ray can intersect with any non-scenery object or can only intersect with objects you have selected. You can use tag(s) to determine which group of objects the ray can intersect with.

Origin Point

The starting world position where the ray will originate from.

Destination Point
  • Position - Define the world position where the ray will travel to and stop.

  • Vector Destination - Define the direction and the length of the ray.

  • Offset Destination - The position relative to the origin position where the ray will stop.

Outputs

X

This is the specific location where the intersection happened along the X axis.

Y

This is the specific location where the intersection happened along the Y axis.

Distance

The behavior will output the distance from the origin to the intersection in meters.

Normal

The behavior will output the normal angle of the intersection. This is the angle of a parallel line to the side of an object that was intersected with.

Intersected

The behavior will output 1 if the ray has intersected with any object. If the ray did not intersect with any object, the behavior will output 0 instead.

AB5B4E7C-664D-46EC-9B77-0787DE10F82B.jpeg

Examples

  • You can check if there's an object in front of your enemy that's blocking its path to the player.
  • You can have a laser that can damage your player but can be blocked off by other physics objects.
  • You can have enemies that chase player on sight - perfect for stealth games where the player can take advantage of their environment to prevent being spotted.

View Demo Project

HitPoint Test