# RaycastResult

## Overview

RaycastResult is a data type that contains result information about what target a raycast actually collided with. It is returned when a WorldRoot:Raycast call succeeds and provides various data needed for raycast result analysis, such as collision point, collided object, and surface information.

## Constructors

## Properties

### Distance

`number`

Represents the straight-line distance from where the Raycast started to where the collision occurred.

#### Code Samples

```lua
local Workspace = game:GetService("Workspace")

local Origin = Vector3.new(0, 50, -0)
local Direction = Vector3.new(0, 0, -3000)

local Result = Workspace:Raycast(Origin, Direction)
if Result then
   print("Hit distance:", Result.Distance)
end
```

### Instance

`Instance`

Represents the target object the Raycast collided with.

#### Code Samples

```lua
local Workspace = game:GetService("Workspace")

local Origin = Vector3.new(0, 50, -0)
local Direction = Vector3.new(0, 0, -3000)

local Result = Workspace:Raycast(Origin, Direction)
if Result then
   print("Hit instance:", Result.Instance.Name)
end
```

### Position

`Vector3`

Represents the position where the Raycast collided with the target as coordinates in world space.

#### Code Samples

```lua
local Workspace = game:GetService("Workspace")

local Origin = Vector3.new(0, 50, -0)
local Direction = Vector3.new(0, 0, -3000)

local Result = Workspace:Raycast(Origin, Direction)
if Result then
   print("Hit position:", Result.Position)
end
```

### Normal

`Vector3`

A vector representing the direction the surface that the Raycast collided with is facing. It is based on the direction perpendicular to the plane at the collision point, and used in subsequent operations such as reflection processing, angle calculation, and surface direction detection.

#### Code Samples

```lua
local Workspace = game:GetService("Workspace")

local Origin = Vector3.new(0, 50, -0)
local Direction = Vector3.new(0, 0, -3000)

local Result = Workspace:Raycast(Origin, Direction)
if Result then
   print("Surface normal:", Result.Normal)
end
```

## Methods

## See also

{% content-ref url="../classes/worldroot" %}
[worldroot](https://docs.overdare.com/development/api-reference/classes/worldroot)
{% endcontent-ref %}
