CREATE YOUR WORLD
Scripting

Raycast

3min

The Raycast function can be used for efficiently finding an Object within a scene in Unity.

Raycast in Unity programming is a kind of laser beam, which will shoot from a location in a scene and shoot until it hits a Collider. When it collides a Collider, the information(RaycastHit) of the collided Object and position within the scene will be returned.

For more details on Unity Raycast, please review the Unity guide.



The Unity Raycast can be used in ZEPETO.Script by completing the following steps:

First, import the Raycast related class.

TypeScript


The following is an example code for the Raycast function:

Raycast




📘 Please refer to the following guide for explanations of the $ref and $unref used in the script. [$ref & $unref]



Through the test code, you can check that the information of the object is output by clicking the Cube with the mouse pointer in the Scene.

Document image




Find more information for the Raycast API used in the ZEPETO.Script by going to the link below.



Updated 10 Oct 2024
Doc contributor
Did this page help you?