# Stop raycast from going through wall

**URL:** <https://forums.unrealengine.com/t/stop-raycast-from-going-through-wall/692627>\
**Category:** Blueprint\
**Tags:** Raycast, unreal-engine, UE5-0, Blueprint, question\
**Created:** [November 17, 2022, 8:35am UTC](https://forums.unrealengine.com/t/stop-raycast-from-going-through-wall/692627 "2022-11-17T08:35:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zapking9224](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/zapking9224/32/1060813_2.png) [@Zapking9224](https://forums.unrealengine.com/u/Zapking9224)\
**Post date:** [November 17, 2022, 8:35am UTC](https://forums.unrealengine.com/t/stop-raycast-from-going-through-wall/692627/1 "2022-11-17T08:35:48Z")

</div>

Hi, so I’m trying to make a system where when the player is looking at the skeletons, they freeze in place and when the player looks away, they start moving again. I have everything about their movement working. Just the logic behind what the player sees is kinda finicky. At this point, I’m using a multi-line box trace to check if they are in view. I got them to stop moving, but I’m unsure how to check when they aren’t being hit by the line trace. And the other issue I’m having is the line trace is going through walls. Any ideas on how to solve any of these problems would be greatly appreciated!

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/c/f/8cf83e968cee7d2b89899e4852111e1a206d4ff5.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/c/d/bcd15033f7059231f379402dadb93e4b9e15b762.png)

---

<div class="post-metadata">

**Author:** ![Quetzalcodename](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Quetzalcodename](https://forums.unrealengine.com/u/Quetzalcodename)\
**Post date:** [November 17, 2022, 11:38am UTC](https://forums.unrealengine.com/t/stop-raycast-from-going-through-wall/692627/2 "2022-11-17T11:38:36Z")

</div>

Hey @Zapking9224!

A few questions and a possible solution to get things started:

- Is there a reason you are using a Multi Line Trace specifically instead of a single line trace?
- Have you tried using a [Multi Line Trace by Channel](https://docs.unrealengine.com/5.0/en-US/using-a-multi-line-trace-raycast-by-channel-in-unreal-engine/)? (by object will go through any object regardless of overlap or blocking. This could potentially solve your problem if you follow the steps in the linked documentation.)
- Additionally, is the collision for your walls set to block all?

> **[Using a Multi Line Trace (Raycast) by Channel](https://docs.unrealengine.com/5.0/en-US/using-a-multi-line-trace-raycast-by-channel-in-unreal-engine/)**
>
> This how-to guide covers using a Multi Line Trace by Channel Blueprint node to return all Actors it hits that respond on the Visibility channel, and prints their names.

Any additional specifics you provide will go a long way in solving your problem!

---

<div class="post-metadata">

**Author:** ![Zapking9224](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/zapking9224/32/1060813_2.png) [@Zapking9224](https://forums.unrealengine.com/u/Zapking9224)\
**Post date:** [November 17, 2022, 11:56am UTC](https://forums.unrealengine.com/t/stop-raycast-from-going-through-wall/692627/3 "2022-11-17T11:56:03Z")

</div>

Hey @Quetzalcodename!  
Here’s a screenshot showing what’s happening here. I’m right now using the multi line trace by channel and the lines are still going through the walls. The reason I’m using the multi line trace is because there are multiple skeletons running around that the player will see. Maybe I’m not understanding the point of using the multi line trace but from what I’m understanding, it’s so it can detect more than one object.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/5/3/c53c920b84684a0e9adbb6243198fab85735870f.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:** [November 17, 2022, 12:33pm UTC](https://forums.unrealengine.com/t/stop-raycast-from-going-through-wall/692627/4 "2022-11-17T12:33:13Z")

</div>

Multitrace is for penetrating overlapping obstacles.

* * *

Consider `Pawn Sensing` instead.

- in the Skelly:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/a/0/3a0659a30d6cff3c41de531d7dc1aa8622851865.jpeg)

- in the Player:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/9/8/d98e8dbdbebac8e65b6a46d96587eb7e65e421a0.jpeg)

Can be improved, surely.

* * *

For something more elaborate and with more control, `dot product`:

> [@Weeping Angels effect](https://forums.unrealengine.com/t/weeping-angels-effect/432807/5):
>
> Maybe it’s not about pausing anything at all per se. Perhaps it’s just about gating the statue’s Tick so it does not execute a part of its script. This simple approach seems to work well enough. Statues follow player: Until the player looks at them: [[Image from Gyazo]](https://gyazo.com/6e36b8f2222be449978461b851dba8f5) There might be a more elegant solution, though.

Have a look at the thread. Some unorthodox (just messing around with stuff) methods there.

---

<div class="post-metadata">

**Author:** ![Zapking9224](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/zapking9224/32/1060813_2.png) [@Zapking9224](https://forums.unrealengine.com/u/Zapking9224)\
**Post date:** [November 18, 2022, 2:33am UTC](https://forums.unrealengine.com/t/stop-raycast-from-going-through-wall/692627/5 "2022-11-18T02:33:09Z")

</div>

Hey @Everynone!  
I got it working to have the skeleton stop when the player is looking at them. However, I’m not sure how to get them to start moving again when the player looks away. I’m using a behavior tree and it runs the move to player branch when the boolean is false and goes to the freeze branch when the boolean is true.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/7/d/97d89448d29ccbda5e9ef01f7a6676081bee22ba.png)

---

<div class="post-metadata">

**Author:** ![Zapking9224](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/zapking9224/32/1060813_2.png) [@Zapking9224](https://forums.unrealengine.com/u/Zapking9224)\
**Post date:** [November 19, 2022, 2:21am UTC](https://forums.unrealengine.com/t/stop-raycast-from-going-through-wall/692627/6 "2022-11-19T02:21:21Z")

</div>

Hey @Everynone!  
So I came up with a solution to unfreezing the skeleton, but it only works on one at a time. It freezes both of them when I look at either one of them, but when I look away from both of them, it only unfreezes one of them and the other stays frozen. The only way to unfreeze the other one is to make sure it’s the most recent one seen which is kinda hard to pull off but it is possible. I’m not sure why it isn’t individually working for both of them.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/6/2/262855c2c40f0e00073a3c8de3c34839a5920596.png)
