# Limit relative movment to Box Collision

**URL:** <https://forums.unrealengine.com/t/limit-relative-movment-to-box-collision/456981>\
**Category:** Blueprint\
**Tags:** child-actors, unreal-engine, bounds, UE4, Blueprint, question\
**Created:** [October 15, 2019, 11:05pm UTC](https://forums.unrealengine.com/t/limit-relative-movment-to-box-collision/456981 "2019-10-15T23:05:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![TuXsOrDs](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TuXsOrDs](https://forums.unrealengine.com/u/TuXsOrDs)\
**Post date:** [October 15, 2019, 11:05pm UTC](https://forums.unrealengine.com/t/limit-relative-movment-to-box-collision/456981/1 "2019-10-15T23:05:34Z")

</div>

I am making a top down rail shooter and I have a player pawn set to move along a spline.  
The player pawn has a box collision and a child actor.  
I have a input axis for both moving the child actor forward, Backward, Left, and right. Relatively.  
I dont want the child actor to be able to move outside of this box collision  
(The box collision is a component of the player pawn)

Here is the blueprints for moving the child actor relatively.

 ![290156-movement.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/d/0/ed0fa62de2d608beea425a3ebb0155148172e815.jpeg)

And here is a list of the components, and the viewport

 ![290157-components-and-viewport.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/f/8/4f8f7980e16d8397f896a422d283c17382b3c8f5.jpeg)

---

<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:** [October 16, 2019, 1:57pm UTC](https://forums.unrealengine.com/t/limit-relative-movment-to-box-collision/456981/2 "2019-10-16T13:57:50Z")

</div>

Although it’s possible to keep the child inside the box with code, why not just make four boxes outside the current one and set them to ‘block all’? That way, the child can move freely with normal code until it hits one of the edges…

---

<div class="post-metadata">

**Author:** ![TuXsOrDs](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TuXsOrDs](https://forums.unrealengine.com/u/TuXsOrDs)\
**Post date:** [October 16, 2019, 3:07pm UTC](https://forums.unrealengine.com/t/limit-relative-movment-to-box-collision/456981/3 "2019-10-16T15:07:34Z")

</div>

I did think about that but I will have enemies all around that the player has to use the child actor to kill (Similar to the game Blackhawk Striker) but if all of the boxes are block all I don’t want it to interfere with any of the enemies.

---

<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:** [October 16, 2019, 3:13pm UTC](https://forums.unrealengine.com/t/limit-relative-movment-to-box-collision/456981/4 "2019-10-16T15:13:45Z")

</div>

Well, you could use a custom collision class, but I agree it’s easier to do that math… 🙂

---

<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:** [October 16, 2019, 3:16pm UTC](https://forums.unrealengine.com/t/limit-relative-movment-to-box-collision/456981/5 "2019-10-16T15:16:00Z")

</div>

I think GetBoundingBox would be useful on the component. If they try to set X or Y coords outside the box, just correct them to the edge of the box…

---

<div class="post-metadata">

**Author:** ![TuXsOrDs](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TuXsOrDs](https://forums.unrealengine.com/u/TuXsOrDs)\
**Post date:** [October 18, 2019, 11:03pm UTC](https://forums.unrealengine.com/t/limit-relative-movment-to-box-collision/456981/6 "2019-10-18T23:03:07Z")

</div>

Sorry for being late but I did end up using a custom collision channel for this and that solved my problem
