# Clamp rotation between two components

**URL:** <https://forums.unrealengine.com/t/clamp-rotation-between-two-components/471699>\
**Category:** XR Development\
**Tags:** rotation, unreal-engine, transform, clamp, question\
**Created:** [September 21, 2020, 3:27pm UTC](https://forums.unrealengine.com/t/clamp-rotation-between-two-components/471699 "2020-09-21T15:27:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Teapot\_Creation](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Teapot\_Creation](https://forums.unrealengine.com/u/Teapot_Creation)\
**Post date:** [September 21, 2020, 3:27pm UTC](https://forums.unrealengine.com/t/clamp-rotation-between-two-components/471699/1 "2020-09-21T15:27:26Z")

</div>

Hey,  
here is a math question (I guess).  
On my pawn, I have a skeletal mesh with a look at, moving along with a motion controller (VR). It’s rotation is defined by the look at and the controller location.  
A child actor is attached to the pawn. I want it to be located where the motioncontroller is, but have a clamped rotation depending on the previous skeletal mesh.  
I know how to define its location and rotation depending the motioncontroller, but how can I limit the rotation ? It has probably something to do with inverse transform rotation and so on, but I can’t figure out what exactly.  
Could someone help me ? Thanks !

---

<div class="post-metadata">

**Author:** ![Teapot\_Creation](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Teapot\_Creation](https://forums.unrealengine.com/u/Teapot_Creation)\
**Post date:** [September 21, 2020, 3:43pm UTC](https://forums.unrealengine.com/t/clamp-rotation-between-two-components/471699/2 "2020-09-21T15:43:13Z")

</div>

In case this was unclear : I want the child actor to be rotating with the motioncontroller but prevent it collides with the skeletal mesh.

---

<div class="post-metadata">

**Author:** ![Teapot\_Creation](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Teapot\_Creation](https://forums.unrealengine.com/u/Teapot_Creation)\
**Post date:** [September 22, 2020, 8:19am UTC](https://forums.unrealengine.com/t/clamp-rotation-between-two-components/471699/3 "2020-09-22T08:19:44Z")

</div>

Okay I’ve got some result with this setup :  
Get skeletal mesh world rotation, get min/max values by subtract/add the clamp value (45° in my case).  
Get the relative rotation of the controller, clamp this rotation with previous defined min/max values and set new actor relative rotation with these. BUT X rotation flicks, I had to remove clamping on X axis.

However I have another child actor which needs a local offset, and this clamping doesn’t work if I add any local rotation offset. Any other idea ?

 ![314533-capture-decran-2020-09-22-102033.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/7/d/77d5672412f6d94f517ac34bb32ce7304aeeda73.jpeg)

---

<div class="post-metadata">

**Author:** ![Teapot\_Creation](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Teapot\_Creation](https://forums.unrealengine.com/u/Teapot_Creation)\
**Post date:** [September 22, 2020, 8:27am UTC](https://forums.unrealengine.com/t/clamp-rotation-between-two-components/471699/4 "2020-09-22T08:27:51Z")

</div>

Nvm I’ve add a local rotation on a children component (added a scene component in the bp).
