# Does boxtrace work the same as linetrace or is it broken?

**URL:** <https://forums.unrealengine.com/t/does-boxtrace-work-the-same-as-linetrace-or-is-it-broken/1626231>\
**Category:** Blueprint\
**Tags:** UE-5, unreal-engine, Blueprint, question\
**Created:** [January 19, 2024, 1:54pm UTC](https://forums.unrealengine.com/t/does-boxtrace-work-the-same-as-linetrace-or-is-it-broken/1626231 "2024-01-19T13:54:05Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yaklakootmaa2](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/yaklakootmaa2/32/1194607_2.png) [@Yaklakootmaa2](https://forums.unrealengine.com/u/Yaklakootmaa2)\
**Post date:** [January 19, 2024, 1:54pm UTC](https://forums.unrealengine.com/t/does-boxtrace-work-the-same-as-linetrace-or-is-it-broken/1626231/1 "2024-01-19T13:54:05Z")

</div>

I was surprised to discover that boxtrace works like linetrace, but I don’t understand what the point is in using it at all.  
Is this a bug or is it intended to be like this?  
Boxtrace hits collision if it crosses the middle of it. I can replace boxtrace with lintrace and will get the same result.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/0/e/40ef03725c19bf747a0e91ee98b3480522997ed7.jpeg)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [January 19, 2024, 1:57pm UTC](https://forums.unrealengine.com/t/does-boxtrace-work-the-same-as-linetrace-or-is-it-broken/1626231/2 "2024-01-19T13:57:19Z")

</div>

> [@Yaklakootmaa2](#):
>
> what the point is in using it at all

- if I line trace, I will miss:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/f/f/7ff2e57d9c8116582de53f29cfc3424af7f2d8d7.png)

- If I box trace, I will hit:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/1/9/919c36a1f602a5657e416c9b3045fe853f005fcd.png)

* * *

If you’re getting a different result, something is not set up correctly.

---

<div class="post-metadata">

**Author:** ![Yaklakootmaa2](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/yaklakootmaa2/32/1194607_2.png) [@Yaklakootmaa2](https://forums.unrealengine.com/u/Yaklakootmaa2)\
**Post date:** [January 19, 2024, 1:58pm UTC](https://forums.unrealengine.com/t/does-boxtrace-work-the-same-as-linetrace-or-is-it-broken/1626231/3 "2024-01-19T13:58:19Z")

</div>

I thought the same as you, but in practice boxtrace doesn’t work that way.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [January 19, 2024, 1:58pm UTC](https://forums.unrealengine.com/t/does-boxtrace-work-the-same-as-linetrace-or-is-it-broken/1626231/4 "2024-01-19T13:58:47Z")

</div>

Yeah, they do.

---

<div class="post-metadata">

**Author:** ![Yaklakootmaa2](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/yaklakootmaa2/32/1194607_2.png) [@Yaklakootmaa2](https://forums.unrealengine.com/u/Yaklakootmaa2)\
**Post date:** [January 19, 2024, 1:59pm UTC](https://forums.unrealengine.com/t/does-boxtrace-work-the-same-as-linetrace-or-is-it-broken/1626231/5 "2024-01-19T13:59:39Z")

</div>

Nope. I tried spheretrace and it works but boxtrace does not

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [January 19, 2024, 2:01pm UTC](https://forums.unrealengine.com/t/does-boxtrace-work-the-same-as-linetrace-or-is-it-broken/1626231/6 "2024-01-19T14:01:19Z")

</div>

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/5/5/d55b93ed05c0e852a719de7cd1b812b569068687.jpeg)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/b/5/9b57859a9c19770716d7c83cac61fe19612290ca.jpeg)

---

<div class="post-metadata">

**Author:** ![Yaklakootmaa2](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/yaklakootmaa2/32/1194607_2.png) [@Yaklakootmaa2](https://forums.unrealengine.com/u/Yaklakootmaa2)\
**Post date:** [January 19, 2024, 2:03pm UTC](https://forums.unrealengine.com/t/does-boxtrace-work-the-same-as-linetrace-or-is-it-broken/1626231/7 "2024-01-19T14:03:28Z")

</div>

Have a look. Spheretrace works as intended  
There is no issue with collision settings or with trace channels

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/7/f/a7f26d47cef724bd5a7a480620485cf34fe48a5c.jpeg)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [January 19, 2024, 2:05pm UTC](https://forums.unrealengine.com/t/does-boxtrace-work-the-same-as-linetrace-or-is-it-broken/1626231/8 "2024-01-19T14:05:23Z")

</div>

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/b/0/2b005d06a1ebcfd2d5532a68699a5c366b3fa53e.jpeg)

The issue is something else than the box trace. Be mindful of how `Extent` works, especially after rotating.

---

<div class="post-metadata">

**Author:** ![Yaklakootmaa2](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/yaklakootmaa2/32/1194607_2.png) [@Yaklakootmaa2](https://forums.unrealengine.com/u/Yaklakootmaa2)\
**Post date:** [January 19, 2024, 2:06pm UTC](https://forums.unrealengine.com/t/does-boxtrace-work-the-same-as-linetrace-or-is-it-broken/1626231/9 "2024-01-19T14:06:29Z")

</div>

I can’t even imagine where it might be because it hits the target but in a broken manner. This is so weird.

PS Yes I know how box extent works 🙂

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [January 19, 2024, 2:08pm UTC](https://forums.unrealengine.com/t/does-boxtrace-work-the-same-as-linetrace-or-is-it-broken/1626231/10 "2024-01-19T14:08:49Z")

</div>

> [@Yaklakootmaa2](#):
>
> I know how box extent works

Are you using Orientation?

---

<div class="post-metadata">

**Author:** ![Yaklakootmaa2](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/yaklakootmaa2/32/1194607_2.png) [@Yaklakootmaa2](https://forums.unrealengine.com/u/Yaklakootmaa2)\
**Post date:** [January 19, 2024, 2:13pm UTC](https://forums.unrealengine.com/t/does-boxtrace-work-the-same-as-linetrace-or-is-it-broken/1626231/12 "2024-01-19T14:13:11Z")

</div>

Yes. World rotation of the arrow component which is directed to the side

---

<div class="post-metadata">

**Author:** ![Yaklakootmaa2](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/yaklakootmaa2/32/1194607_2.png) [@Yaklakootmaa2](https://forums.unrealengine.com/u/Yaklakootmaa2)\
**Post date:** [January 19, 2024, 2:14pm UTC](https://forums.unrealengine.com/t/does-boxtrace-work-the-same-as-linetrace-or-is-it-broken/1626231/13 "2024-01-19T14:14:50Z")

</div>

Simple stuff  
RightSideCentralTrace is arrow component

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/c/f/4cfdf82e549f1c5de69a1494838552b39a285e98.jpeg)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [January 19, 2024, 2:16pm UTC](https://forums.unrealengine.com/t/does-boxtrace-work-the-same-as-linetrace-or-is-it-broken/1626231/14 "2024-01-19T14:16:40Z")

</div>

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/b/8/5b8666c0ae99684018f9939fb0912be96b958076.jpeg)

is this is a static value? Can you try with it punched in manually, just to test. Hard to imagine it without seeing the whole thing.

* * *

Are you deriving those values from components bounds?

> Be mindful of how `Extent` works, especially after rotating.

There’s no need to update the Half Size (extent) if you’re changing orientation. Try with orientation only - see how it goes. Set the Half Size only once, at Begin Play, don’t update it later.

---

<div class="post-metadata">

**Author:** ![Yaklakootmaa2](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/yaklakootmaa2/32/1194607_2.png) [@Yaklakootmaa2](https://forums.unrealengine.com/u/Yaklakootmaa2)\
**Post date:** [January 19, 2024, 2:26pm UTC](https://forums.unrealengine.com/t/does-boxtrace-work-the-same-as-linetrace-or-is-it-broken/1626231/15 "2024-01-19T14:26:17Z")

</div>

Omg it works now. Will check the variable. I get it From GetScaledBoxExtent  
Thank you very much!

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/d/6/dd6aed2738d1e4f26d7be87ecd14cbb74ec95ad2.jpeg)

---

<div class="post-metadata">

**Author:** ![Yaklakootmaa2](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/yaklakootmaa2/32/1194607_2.png) [@Yaklakootmaa2](https://forums.unrealengine.com/u/Yaklakootmaa2)\
**Post date:** [January 19, 2024, 2:27pm UTC](https://forums.unrealengine.com/t/does-boxtrace-work-the-same-as-linetrace-or-is-it-broken/1626231/16 "2024-01-19T14:27:58Z")

</div>

I make this box extent once in construction script but need to check the output, why it looks right but boxtrace doesn’t work

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [January 19, 2024, 2:33pm UTC](https://forums.unrealengine.com/t/does-boxtrace-work-the-same-as-linetrace-or-is-it-broken/1626231/17 "2024-01-19T14:33:22Z")

</div>

> [@Yaklakootmaa2](#):
>
> I make this box extent once in construction script

And that’s another _potential_ trap UE sets for you. Due to the way comps are re-instantiated, we cannot always rely on their data in the CS. I [learnt it the hard way](https://forums.unrealengine.com/t/why-does-the-construction-script-refuse-to-report-component-offsets/464489) a couple of ways ago. The entry is in the bug DB but is flagged as Won’t Fix. Acknowledged but _Waived_.

It may work here & there but through the sheer force of habit I set the value once on Begin Play and only update it when the size actually changes - let’s say you added a giant cargo hold that pokes out to the spaceship (?).

* * *

In short:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/4/a/d4a92092b5ffe4caf830aa5e7855470489936a22.jpeg)

The component _forgets_ where it is, for example.

---

<div class="post-metadata">

**Author:** ![Yaklakootmaa2](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/yaklakootmaa2/32/1194607_2.png) [@Yaklakootmaa2](https://forums.unrealengine.com/u/Yaklakootmaa2)\
**Post date:** [January 19, 2024, 2:35pm UTC](https://forums.unrealengine.com/t/does-boxtrace-work-the-same-as-linetrace-or-is-it-broken/1626231/18 "2024-01-19T14:35:55Z")

</div>

Thanks for the detailed information, I’ll try to avoid this problem.

Fortunately, I don’t need to change the size of the ship in runtime. I’ll do it all on beginplay

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [February 18, 2024, 2:36pm UTC](https://forums.unrealengine.com/t/does-boxtrace-work-the-same-as-linetrace-or-is-it-broken/1626231/19 "2024-02-18T14:36:34Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
