# Restrict Pawn's Rotation

**URL:** <https://forums.unrealengine.com/t/restrict-pawns-rotation/487856>\
**Category:** Community & Industry Discussion\
**Tags:** unreal-engine, rotate, question\
**Created:** [August 23, 2021, 7:30am UTC](https://forums.unrealengine.com/t/restrict-pawns-rotation/487856 "2021-08-23T07:30:40Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![cruisy18](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@cruisy18](https://forums.unrealengine.com/u/cruisy18)\
**Post date:** [August 23, 2021, 7:30am UTC](https://forums.unrealengine.com/t/restrict-pawns-rotation/487856/1 "2021-08-23T07:30:40Z")

</div>

Hi all

I have a turret which automatically looks at the player and starts shooting. This functionality works well.

Now, I want to restrict the turret’s rotation capability so that it can’t rotate behind, it can’t look directly down etc.

What is the best way to go about this? Attached is a screenshot of my current Blueprint of the turret.

If any further information is required, please let me know.

Cheers

Matt

 ![346987-pawnrotate.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/6/3/163757a842e849e4eaa9eefe2f734d58011c1c13.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 23, 2021, 7:57am UTC](https://forums.unrealengine.com/t/restrict-pawns-rotation/487856/2 "2021-08-23T07:57:18Z")

</div>

Hi Cruisy.

Does the rotation look a little strange by any chance? It will work better if you get the current rotation before going into the timeline, rather than sampling it during.

Anyway… the clamp node is your friend. You can make sure the rotation values stay within certain bounds.

---

<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:** [August 23, 2021, 8:15am UTC](https://forums.unrealengine.com/t/restrict-pawns-rotation/487856/3 "2021-08-23T08:15:44Z")

</div>

Have a look at this one:

 ![346990-turret.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/6/5/165727f94133cbbff2147c926d27b3b1fdb8bf31.jpeg)

Script to copy:

> **[Turret with angle limit posted by anonymous | blueprintUE | PasteBin For...](https://blueprintue.com/blueprint/9oq18aj5/)**
>
> No description provided

[![Image from Gyazo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/a/9/da94506ed9628235b121326f102c4c385f84d320.gif)](https://gyazo.com/07facc8d174c94dd6103a641878c6929)

Essentially, Dot Product is an answer to most angular issues. The yellow arrow indicates the turret’s front.

* * *

Oh, and a TL is probably not the way to go about it unless you’re after something truly specific / unique / inflexible. Does not mesh well with target tracking in my head.

---

<div class="post-metadata">

**Author:** ![cruisy18](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@cruisy18](https://forums.unrealengine.com/u/cruisy18)\
**Post date:** [August 23, 2021, 9:16am UTC](https://forums.unrealengine.com/t/restrict-pawns-rotation/487856/4 "2021-08-23T09:16:11Z")

</div>

Thanks Clockwork and Everynone. That Blueprint website is handy.

I have tried to implement it but I am still having issues, can you see what I am doing wrong?

> **[TurretBP posted by cruisy18 | blueprintUE | PasteBin For Unreal Engine 4](https://blueprintue.com/blueprint/tqjqp2vc/)**
>
> No description provided

Cheers

Matt

---

<div class="post-metadata">

**Author:** ![cruisy18](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@cruisy18](https://forums.unrealengine.com/u/cruisy18)\
**Post date:** [August 23, 2021, 9:36am UTC](https://forums.unrealengine.com/t/restrict-pawns-rotation/487856/5 "2021-08-23T09:36:51Z")

</div>

EDIT: I think I actually figured it out. I have updated the Blueprint link above.

Please let me know if you see any issues.

---

<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:** [August 23, 2021, 9:45am UTC](https://forums.unrealengine.com/t/restrict-pawns-rotation/487856/6 "2021-08-23T09:45:03Z")

</div>

You need to run this on Tick. If we want to see an update every frame (the animation), we need to interpolate every frame - that’s what the Timelines’ Update does as well. Interpolation relies on the data from the previous step.

Can’t recall how often Pawn sensing updates by default? Once a second, maybe twice. So you’d need to Sense the Pawn → Open the Gate for Tick so the script runs only when a Pawn is nearby - you could probably use the _VisionRadius_ or whatshername.

---

<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:** [August 23, 2021, 9:58am UTC](https://forums.unrealengine.com/t/restrict-pawns-rotation/487856/7 "2021-08-23T09:58:38Z")

</div>

Just to clarify:

[![Image from Gyazo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/6/8/f685d571790de63d6d26faf35773960431857d1b.gif)](https://gyazo.com/d85aeee26dd5c1117565318e731a86fa)

This is based on Distance from the Player but, ideally, should also incorporate the angle so the whole thing switches off (disable Tick, mayhap?) when the player is far away _and_ outside of the vision cone. The vision cone is already calculated so you could leverage that.

But ofc, you may have a different idea as to when the turret’s target seeking script kicks in!

---

<div class="post-metadata">

**Author:** ![cruisy18](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@cruisy18](https://forums.unrealengine.com/u/cruisy18)\
**Post date:** [August 23, 2021, 10:09am UTC](https://forums.unrealengine.com/t/restrict-pawns-rotation/487856/8 "2021-08-23T10:09:00Z")

</div>

Hey that’s working really well, thanks!

---

<div class="post-metadata">

**Author:** ![MikelKram](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mikelkram/32/1011745_2.png) [@MikelKram](https://forums.unrealengine.com/u/MikelKram)\
**Post date:** [March 22, 2024, 10:08pm UTC](https://forums.unrealengine.com/t/restrict-pawns-rotation/487856/9 "2024-03-22T22:08:24Z")

</div>

> [@Camera clamp is always based on the world coordinate X.](https://forums.unrealengine.com/t/camera-clamp-is-always-based-on-the-world-coordinate-x/1765800):
>
> Сamera Rotation Clamp Works, BUT… after the movement stops, the camera randomly selects an angle for the clamp. Clamp ON: Clamp RESET: Video showing that it works correctly at the beginning, but then randomly selects angles + also rotates the camera.

i dont understand
