> For the complete documentation index, see [llms.txt](https://docs.anvil.team/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.anvil.team/types/trace.md).

# trace

Ray tracing

{% hint style="info" %}
A trace can be useful if you want to get the location of blocking things.\
You will have to use a appropriate start position, often it can be your forward vector.\
\
The `fraction` ranges from 0 to 1 and tells you at how many % the trace hit something.\
For example if you trace from the origin <mark style="color:purple;">`(0, 0, 0)`</mark> to <mark style="color:purple;">`(0, 0, 1000)`</mark> and the fraction is <mark style="color:green;">`0.5`</mark>, that means there is a blocking object at <mark style="color:purple;">`(0, 0, 500)`</mark>

While the calculation is simple, we're providing a helper method\
to obtain the hit location [here](#gethitlocation-start-end).
{% endhint %}

### Properties

* <mark style="color:purple;">`fraction`</mark>
* <mark style="color:purple;">`normal`</mark>
* <mark style="color:purple;">`surfaceFlags`</mark>
* <mark style="color:purple;">`contents`</mark>
* <mark style="color:purple;">`allSolid`</mark>
* <mark style="color:purple;">`startSolid`</mark>
* <mark style="color:purple;">`walkable`</mark>

### Methods

### <mark style="color:green;">`getHitLocation(start, end)`</mark>

Returns the hit position of the trace.

**Example:**

```lua
local pointA = Vec3:new(0, 0, 0)
local pointB = Vec3:new(0, 0, 1000)
local trace = engine.trace(pointA, pointB)
local hitPosition = trace.getHitLocation()

if (trace.fraction < 1) then
    print("Hit something at: " .. hitPosition:toString())
end
```
