# Programmatically lock rotation axis not working

**URL:** <https://forums.unrealengine.com/t/programmatically-lock-rotation-axis-not-working/476455>\
**Category:** World Creation\
**Tags:** Constraints, unreal-engine, lock, constraint, Physics, CPP, question\
**Created:** [December 27, 2020, 4:35pm UTC](https://forums.unrealengine.com/t/programmatically-lock-rotation-axis-not-working/476455 "2020-12-27T16:35:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fatorice](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fatorice](https://forums.unrealengine.com/u/Fatorice)\
**Post date:** [December 27, 2020, 4:35pm UTC](https://forums.unrealengine.com/t/programmatically-lock-rotation-axis-not-working/476455/1 "2020-12-27T16:35:30Z")

</div>

Hi!

I’m trying to lock the physics rotation axis programmatically using c++.  
Here’s my code I’m using (exposed to and called from blueprints), but it’s not working:

```
void UUtility::SetRotationAxisLock(UPrimitiveComponent* Component, const bool bLockX, const bool bLockY,
                                   const bool bLockZ)
{
	Component->BodyInstance.bLockXRotation = bLockX;
	Component->BodyInstance.bLockYRotation = bLockY;
	Component->BodyInstance.bLockZRotation = bLockZ;
}

```

Do you have an idea on how to fix this or is there another way to change the rotation lock constraints during runtime from blueprints?  
Thank you very much!
