Case Status
Log In


Home ยป Action Reference»Physics Actions»Raycast
Community Wiki


Casts a ray against all colliders in the scene.

Use either a game object or vector3 world position as the origin of the ray.

Use GetRaycastInfo to get more detailed info on the results.

From Game Object
Start ray at game object position. Or use Origin parameter.
From Position
Start ray at a vector3 world position. Or use Game Object parameter.
A vector3 direction vector
The length of the ray. Set to -1 for infinity.
Hit Event
Event to send if the ray hits an object.
Store Did Hit
Set a bool variable to true if hit something, otherwise false.
Store Hit Object
Store the game object hit in a variable.
Repeat Interval
Set how often to cast a ray. 0 = once, don't repeat; 1 = everyFrame; 2 = every other frame... Since raycasts can get expensive use the highest repeat interval you can get away with.
Draw a debug ray. Set the color of the ray in Preferences.



Check Debug and Enable Gizmos to see the ray in the Game View.

Local Space

Raycast takes a direction in world space. To raycast in local space use Transform Direction to convert a local space direction to a world space direction. For example, Transform Direction with x = 0, y = 0, z = 1 to get get a world direction vector looking forward.


Raycast doesn't support a LayerMask yet, but you can move colliders to the Ignore Raycast Layer if you don't want a raycast to pick them.



Last modified on 2/28/2011 10:40 PM by User.

  • RSS Feed