# Camera clipping breaks my line trace RESOLVED

**URL:** <https://forums.unrealengine.com/t/camera-clipping-breaks-my-line-trace-resolved/487471>\
**Category:** Rendering\
**Tags:** line-trace, linetrace, clipping, unreal-engine, Blueprint, question\
**Created:** [August 15, 2021, 4:20pm UTC](https://forums.unrealengine.com/t/camera-clipping-breaks-my-line-trace-resolved/487471 "2021-08-15T16:20:40Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![angelens](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/angelens/32/88715_2.png) [@angelens](https://forums.unrealengine.com/u/angelens)\
**Post date:** [August 15, 2021, 4:20pm UTC](https://forums.unrealengine.com/t/camera-clipping-breaks-my-line-trace-resolved/487471/1 "2021-08-15T16:20:40Z")

</div>

Hey everyone, I set up a projectile with line trace but this breaks when the camera is clipped into an object. I need to change the start position of the line trace based on if it’s clipping but I have no idea on how to do this. Anyone with ideas?

Image 1: blueprint where line trace is created

Image 2: normal trace when not clipping

Image 3: trace goes wrong when clipping

 ![346344-1.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/d/f/3df7f9be3ee2ca3cdd7e5cc3c672f7bfdc602a0e.jpeg)

 ![346345-2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/3/f/a3f8bab9e5773afc7276ac22adec058165346131.png)

 ![346346-3.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/b/e/fbe4664cd238ea83966b4a72d27bfcf5d9f14225.png)

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [August 15, 2021, 6:18pm UTC](https://forums.unrealengine.com/t/camera-clipping-breaks-my-line-trace-resolved/487471/2 "2021-08-15T18:18:14Z")

</div>

Why even consider the camera and the boom in the equation. Surely you want to start the trace from the player?

---

<div class="post-metadata">

**Author:** ![angelens](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/angelens/32/88715_2.png) [@angelens](https://forums.unrealengine.com/u/angelens)\
**Post date:** [August 16, 2021, 1:32pm UTC](https://forums.unrealengine.com/t/camera-clipping-breaks-my-line-trace-resolved/487471/3 "2021-08-16T13:32:08Z")

</div>

How would you line trace from the player correctly?

The reason for using the boom is because I let the player zoom in and out the camera and this also changes the start of the trace. The reason for using the camera is because this way it would always offset correctly (crosshair is a bit to the right top of player).

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [August 16, 2021, 1:39pm UTC](https://forums.unrealengine.com/t/camera-clipping-breaks-my-line-trace-resolved/487471/4 "2021-08-16T13:39:58Z")

</div>

Like this:

 ![346431-screenshot-2.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/e/8/ee83e9ffcd491337b0d40fc60f081313fc5722e0.jpeg)

---

<div class="post-metadata">

**Author:** ![angelens](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/angelens/32/88715_2.png) [@angelens](https://forums.unrealengine.com/u/angelens)\
**Post date:** [August 16, 2021, 1:58pm UTC](https://forums.unrealengine.com/t/camera-clipping-breaks-my-line-trace-resolved/487471/5 "2021-08-16T13:58:30Z")

</div>

This is the result I get (so thats not centering correctly even when not clipping)

 ![346433-1.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/e/5/1e5125a7843cbe647861f0650f7451426aff1330.png)

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [August 16, 2021, 2:05pm UTC](https://forums.unrealengine.com/t/camera-clipping-breaks-my-line-trace-resolved/487471/6 "2021-08-16T14:05:13Z")

</div>

Hmmm… the forward vector from the mesh, does just point directly forward. And yet you have a line going off at an angle, not sure how you’re doing that 😉

It should come out from the waist.

In the end, I’d use the head direction, I think that’s the good direction for the spell, but for now, it’s good to get the mesh working.

Can you show the code?

EDIT: Hold on, my bad…

Right, so it should be right vector for that mesh, never mind. You can also do it from the arrow ( or put your own arrow in to avoid the error you get ):

 ![346434-screenshot-4.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/9/f/79f7c5ed53bdf8f9837f46747b5faf32a507e56b.jpeg)

 ![346435-screenshot-5.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/7/1/771e8b7e43655d8b9e55b6c93e8572c078240871.jpeg)

---

<div class="post-metadata">

**Author:** ![angelens](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/angelens/32/88715_2.png) [@angelens](https://forums.unrealengine.com/u/angelens)\
**Post date:** [August 16, 2021, 2:20pm UTC](https://forums.unrealengine.com/t/camera-clipping-breaks-my-line-trace-resolved/487471/7 "2021-08-16T14:20:21Z")

</div>

Got better results now, the only problem now is that the spell is not centered

 ![346436-1.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/b/5/fb5884163b2525188f80f259a228617b4e6dc937.png)

 ![346437-2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/f/5/9f5c09db7c21edeaf641463ec44fe0a70221c0ba.png)

![346438-3.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/d/1/1d154d65c6cd5b5271f1bd6c9d005824cf57576a.png)

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [August 16, 2021, 2:23pm UTC](https://forums.unrealengine.com/t/camera-clipping-breaks-my-line-trace-resolved/487471/8 "2021-08-16T14:23:45Z")

</div>

By centered, do you mean in that cursor I see?

How are you drawing that?

---

<div class="post-metadata">

**Author:** ![angelens](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/angelens/32/88715_2.png) [@angelens](https://forums.unrealengine.com/u/angelens)\
**Post date:** [August 16, 2021, 2:29pm UTC](https://forums.unrealengine.com/t/camera-clipping-breaks-my-line-trace-resolved/487471/9 "2021-08-16T14:29:42Z")

</div>

Yes correct I’m trying to make it cast to where the cursor / crosshair is every time. The crosshair is drawn in the center of the screen and is always fixed in that position

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [August 16, 2021, 2:38pm UTC](https://forums.unrealengine.com/t/camera-clipping-breaks-my-line-trace-resolved/487471/10 "2021-08-16T14:38:05Z")

</div>

Then you might need to do some sort of projection from screen space to world space to get the end point of the trace. Take a look at:

![346439-screenshot-6.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/c/2/ac22a954fa58249f8a7bc8018cc0388441e825e5.jpeg)

I can’t look right now, but might be able to help later if you get stuck.

---

<div class="post-metadata">

**Author:** ![angelens](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/angelens/32/88715_2.png) [@angelens](https://forums.unrealengine.com/u/angelens)\
**Post date:** [August 16, 2021, 2:49pm UTC](https://forums.unrealengine.com/t/camera-clipping-breaks-my-line-trace-resolved/487471/11 "2021-08-16T14:49:32Z")

</div>

I got it working with this code! Is this good practise?

 ![346440-1.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/b/f/8bff7cfc8af6731a2da54534b2f7fe25d4482b88.png)

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [August 16, 2021, 5:54pm UTC](https://forums.unrealengine.com/t/camera-clipping-breaks-my-line-trace-resolved/487471/12 "2021-08-16T17:54:13Z")

</div>

It looks very logical, well done 🙂

---

<div class="post-metadata">

**Author:** ![EdHarrington](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@EdHarrington](https://forums.unrealengine.com/u/EdHarrington)\
**Post date:** [January 1, 2023, 8:05pm UTC](https://forums.unrealengine.com/t/camera-clipping-breaks-my-line-trace-resolved/487471/13 "2023-01-01T20:05:17Z")

</div>

Did you ever find a solution for the near object clipping? From the looks of it, this code still looks like it won’t resolve for when the camera passes into a nearby object.
