# RayCast2

## About

[**RayCast2**](https://www.roblox.com/library/7302354349/RayCast2) is an easy to use, accurate and documented Raycasting module, specifically for Guis and 2D Game development. Its similar to how Raycasting works when using parts in Roblox studio. If you are into 2D game development, this module is for you!

[Raycasting](https://en.wikipedia.org/wiki/Ray_casting) is a very beneficial concept. Read more about it on the wiki: <https://en.wikipedia.org/wiki/Ray_casting>

## Why use RayCast2?

2D Game development engine features are not present in a wide variety in Roblox studio, therefore I created this module to ease development for some of you. This module is an accurate and easy to use ray casting module for guis.

*`"Oh thats easy to make! Why use it then?"`*

RayCast2 not only is accurate but also works with Rotated gui elements!

*`"Ha! What if there was another gui in front of that?!"`*

If there was. It'll work as expected! It'll strike the gui that comes in its way first!

*`"Hmm, that ray points in only 1 direction, what if I wanted to make diagonal rays??"`*

This module has got your back, it can cast rays in any direction!

Raycasting on a 2D surface can be used in many areas of a 2D game. For example:

* Identifying obstacles
* Making AI
* Turrets&#x20;
* Projectiles
* Other such mechanics


---

# Agent Instructions: 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:

```
GET https://jaipack17.gitbook.io/raycast2/master.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
