> For the complete documentation index, see [llms.txt](https://doc.realvirtual.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.realvirtual.io/components-and-scripts/sensors/measureraycast.md).

# MeasureRaycast

MeasureRaycast is measuring distances between the pivot point of the Gameobject, the MeasureRaycast script is attached to and a collider or between two colliders.

MeasureRaycast is using the Unity Raycast system for sending rays ino the desired direction and detecting collisions and distances. You need to attach a collider to the 3D meshes you want to detect.

You can also connect the result of the measurement to a PLCInput Signal. By doing this MeasureRaycast is able to act as a sensor.

<figure><img src="/files/iU46GS1xnsFrZqKG10IZ" alt=""><figcaption></figcaption></figure>

You can apply the following properties:

| Property                  | Description                                                                                                                                                                                                             |
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| RaycastDirection          | The direction of the Raycast in local coordinate system                                                                                                                                                                 |
| Measure between colliders | If set to true the measurement is not performed between the pivot point and a collider. Instead rays are set into two directions from the pivot point and the distance between the two detected collisions is measured. |
| Raycast Length            | Defines the maximum length of the raycast in one direction. If you measure between two colliders the total measured maximum distance is twice this given distance.                                                      |
| Display Raycast           | Needs to be set to true if you want to see a line in Scene window for the raycast. The line will be red on collision and yellow if no collision is detected.                                                            |
| Raycast to layer          | The raycast is always performed only on one layer. As default it is the Default Layer. If you colliders are on a different Layer you need to change this.                                                               |
| Use Millimeters           | If set to true as a result one Unity Unit will be transformed to 1000.                                                                                                                                                  |
| PLCSignalOffset           | A signal offset value which is added to the measurement result.                                                                                                                                                         |
| DisplayDistance           | Displays the distance of the raycast in Scene Window.                                                                                                                                                                   |
| Measured Distance         | The measured distance as PLCInputFloat. It is 0 if no collision is detected.                                                                                                                                            |
| Raycast Hit               | A PLCInputBool which will be true if the raycast hits an object.                                                                                                                                                        |

\
© 2025 realvirtual GmbH [https://realvirtual.io](https://realvirtual.io/) - All rights reserved. No part of this publication may be reproduced, distributed, or transmitted in any form or by any means, including printing, saving, photocopying, recording, or other electronic or mechanical methods, without the prior written permission of the publisher.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://doc.realvirtual.io/components-and-scripts/sensors/measureraycast.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
