# How can I set bounds for a SpectatorPawn?

**URL:** <https://forums.unrealengine.com/t/how-can-i-set-bounds-for-a-spectatorpawn/2142052>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, question\
**Created:** [November 21, 2024, 11:35pm UTC](https://forums.unrealengine.com/t/how-can-i-set-bounds-for-a-spectatorpawn/2142052 "2024-11-21T23:35:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nyan23](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@nyan23](https://forums.unrealengine.com/u/nyan23)\
**Post date:** [November 21, 2024, 11:35pm UTC](https://forums.unrealengine.com/t/how-can-i-set-bounds-for-a-spectatorpawn/2142052/1 "2024-11-21T23:35:21Z")

</div>

I would like to limit my pawn movement to some bounds (especially z axis) if possible without colliders, by just setting max for x, y, z.

---

<div class="post-metadata">

**Author:** ![Nawrot](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nawrot/32/618260_2.png) [@Nawrot](https://forums.unrealengine.com/u/Nawrot)\
**Post date:** [November 22, 2024, 12:20am UTC](https://forums.unrealengine.com/t/how-can-i-set-bounds-for-a-spectatorpawn/2142052/2 "2024-11-22T00:20:58Z")

</div>

Pawn has input, ignore it if move would exceed limit of Z value. Or better yet ignore moving up if Z is on max limit.

You can also put trigger volume, and hook to its event for pawn leaving volume, but then it may be tricky to move pawn back inside. That moving back is kind of same code for just comparing to Z (or other bounds from above). So trigger volume just doubles code, does not help really.

---

<div class="post-metadata">

**Author:** ![nyan23](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@nyan23](https://forums.unrealengine.com/u/nyan23)\
**Post date:** [November 22, 2024, 1:02am UTC](https://forums.unrealengine.com/t/how-can-i-set-bounds-for-a-spectatorpawn/2142052/4 "2024-11-22T01:02:24Z")

</div>

> Pawn has input, ignore it if move would exceed limit of Z value

```auto
void ABasePawn::MoveUp_World(const float Val)
{
    if (Val != 0.f)
    {
        if (const float CurrentZ = GetActorLocation().Z; Val > 0.f && CurrentZ >= 25000.f)
        {
            return;
        }
        AddMovementInput(FVector::UpVector, Val);
    }
}

```

I guess this works for now. thanks!

---

<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:** [December 22, 2024, 1:02am UTC](https://forums.unrealengine.com/t/how-can-i-set-bounds-for-a-spectatorpawn/2142052/5 "2024-12-22T01:02:48Z")

</div>

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