# How to make a character stop walking when hitting a wall

**URL:** <https://forums.unrealengine.com/t/how-to-make-a-character-stop-walking-when-hitting-a-wall/2293715>\
**Category:** Blueprint\
**Tags:** unreal-engine, Blueprint, question\
**Created:** [January 20, 2025, 5:26pm UTC](https://forums.unrealengine.com/t/how-to-make-a-character-stop-walking-when-hitting-a-wall/2293715 "2025-01-20T17:26:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![VioletSpider9891](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@VioletSpider9891](https://forums.unrealengine.com/u/VioletSpider9891)\
**Post date:** [January 20, 2025, 5:26pm UTC](https://forums.unrealengine.com/t/how-to-make-a-character-stop-walking-when-hitting-a-wall/2293715/1 "2025-01-20T17:26:21Z")

</div>

Hello, I am new to UE5 and I wanted to know if anyone could help me. I have a problem with the character. When he moves towards the wall, he continues walking with the animation. Is there a way to make the player return to the idle animation or stop him from walking?

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/9/f/c9ff771ef36ca1ac9007cdb73c1d8cf40b9a3cb7.png)

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/8/2/a821e2792be13528f018208227150dbc09b62f35.jpeg "2025 01 19 14 40 16") ](https://www.youtube.com/watch?v=_QqF3u3YcDg)

---

<div class="post-metadata">

**Author:** ![VisAgilis](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/visagilis/32/891043_2.png) [@VisAgilis](https://forums.unrealengine.com/u/VisAgilis)\
**Post date:** [January 20, 2025, 6:29pm UTC](https://forums.unrealengine.com/t/how-to-make-a-character-stop-walking-when-hitting-a-wall/2293715/2 "2025-01-20T18:29:13Z")

</div>

Get a `Line Trace by Channel` node and place it right after the `Triggered` pin of your IA. Then get the player character’s location with the `Get Actor Location` node and plug it into the `Start` pin of the line trace node. Then get the `Get Actor Forward Vector` node, multiply it with something like 200 using the multiplication node and add the actor’s location to it using the addition node, then plug the result into the `End` pin of the line trace node. Connect the `Return Value` of the line trace to the `Condition` pin of a `Branch` node and trigger your `Add Movement Input` nodes after it’s `False` pin.

Hope this helps! 😇

---

<div class="post-metadata">

**Author:** ![VioletSpider9891](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@VioletSpider9891](https://forums.unrealengine.com/u/VioletSpider9891)\
**Post date:** [January 21, 2025, 4:04pm UTC](https://forums.unrealengine.com/t/how-to-make-a-character-stop-walking-when-hitting-a-wall/2293715/4 "2025-01-21T16:04:50Z")

</div>

Thanks for your reply, it worked but it stopped all movement. Do you know a way so I can make the movement backward, right and left work except forward?

---

<div class="post-metadata">

**Author:** ![VisAgilis](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/visagilis/32/891043_2.png) [@VisAgilis](https://forums.unrealengine.com/u/VisAgilis)\
**Post date:** [January 21, 2025, 4:18pm UTC](https://forums.unrealengine.com/t/how-to-make-a-character-stop-walking-when-hitting-a-wall/2293715/5 "2025-01-21T16:18:09Z")

</div>

Right 😅 I designed that logic in my mind since I wasn’t on my PC so I wasn’t able to test it for myself.

So to fix that, instead of fixing the line trace to where the player character’s body is facing, you can cast it towards the direction of the movement input.

Make a vector with the `Make Vector` node, and set it’s x & y components to your x & y action values. Rotate this unit vector to the control rotation by getting the `Rotate Vector` node, connecting our vector to it’s yellow pin at the top, then getting the `Get Control Rotation` node and connecting it to the purplish-grey pin at the bottom. The rest would be the same, just multiply the result with something like 200, add the actor’s location onto it and connect it to the `End` pin of the line trace node.

Hope this helps! 😊

---

<div class="post-metadata">

**Author:** ![VioletSpider9891](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@VioletSpider9891](https://forums.unrealengine.com/u/VioletSpider9891)\
**Post date:** [January 21, 2025, 5:46pm UTC](https://forums.unrealengine.com/t/how-to-make-a-character-stop-walking-when-hitting-a-wall/2293715/7 "2025-01-21T17:46:26Z")

</div>

I tried to do the same thing you said but it came out bad. I think I did something wrong. How can I get x and y values? I’m sorry to bother you. I’m new to this. 😅

 ![Screenshot 2025-01-21 202043](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/8/a/78a0ade069ce66fcb1102482d2113bbc1f0688d1.png)

---

<div class="post-metadata">

**Author:** ![VisAgilis](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/visagilis/32/891043_2.png) [@VisAgilis](https://forums.unrealengine.com/u/VisAgilis)\
**Post date:** [January 21, 2025, 6:04pm UTC](https://forums.unrealengine.com/t/how-to-make-a-character-stop-walking-when-hitting-a-wall/2293715/8 "2025-01-21T18:04:36Z")

</div>

The control rotation should be dragged out of the player controller 😊

> [@VioletSpider9891](#):
>
> How can I get x and y values?

I think you’re already doing it. But you can as well right click on the `Action Value` pin of your IA and hit the `Split Struct Pin` option on the menu that pops up.

But you did follow the given steps perfectly 🤩

---

<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 20, 2025, 6:05pm UTC](https://forums.unrealengine.com/t/how-to-make-a-character-stop-walking-when-hitting-a-wall/2293715/9 "2025-02-20T18:05:23Z")

</div>

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