# How do I lock an actor in place with C++?

**URL:** <https://forums.unrealengine.com/t/how-do-i-lock-an-actor-in-place-with-c/545528>\
**Category:** C++\
**Tags:** unreal-engine, UE4, CPP, UE4-27, question\
**Created:** [May 1, 2022, 10:21am UTC](https://forums.unrealengine.com/t/how-do-i-lock-an-actor-in-place-with-c/545528 "2022-05-01T10:21:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![StrUng1132](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@StrUng1132](https://forums.unrealengine.com/u/StrUng1132)\
**Post date:** [May 1, 2022, 10:21am UTC](https://forums.unrealengine.com/t/how-do-i-lock-an-actor-in-place-with-c/545528/1 "2022-05-01T10:21:17Z")

</div>

Hi, I was wondering if there was a method I could call that would enable me to lock an actor in place or if I need to do it from scratch. I tried using the bLockLocation bool but with no luck, does anyone know how to do it?

Thanks,

---

<div class="post-metadata">

**Author:** ![ChrissWalters](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ChrissWalters](https://forums.unrealengine.com/u/ChrissWalters)\
**Post date:** [May 1, 2022, 11:09am UTC](https://forums.unrealengine.com/t/how-do-i-lock-an-actor-in-place-with-c/545528/2 "2022-05-01T11:09:05Z")

</div>

What is your intention here?

For example, you can mark the Actor as Statc in Editor.  
Or by Script (pseudocode!):

bool isMoveable;  
Vector3 StaticLocation;  
…  
OnTick()  
{  
if isMoveable==false  
{  
if ActorLocation != StaticLocation  
{  
Actor.Location = StaticLocation  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![StrUng1132](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@StrUng1132](https://forums.unrealengine.com/u/StrUng1132)\
**Post date:** [May 1, 2022, 3:52pm UTC](https://forums.unrealengine.com/t/how-do-i-lock-an-actor-in-place-with-c/545528/3 "2022-05-01T15:52:27Z")

</div>

What I want to do is basically whenever this actor overlaps a trigger box, the actor will stay in the same position it was in when it first overlapped the trigger box

---

<div class="post-metadata">

**Author:** ![jwatte](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jwatte/32/744941_2.png) [@jwatte](https://forums.unrealengine.com/u/jwatte)\
**Post date:** [May 1, 2022, 6:06pm UTC](https://forums.unrealengine.com/t/how-do-i-lock-an-actor-in-place-with-c/545528/4 "2022-05-01T18:06:36Z")

</div>

An actor doesn’t actually move by itself at all! Instead, actors are moved by other objects, either something like direct action from the game or a Controller (which is a bit of a hack,) or through some kind of MovementComponent (which is the preferred/better way.)

There are many things that can move an actor.

It may be simulating physics, in which case you need to turn off physics simulation.  
It may be using a CharacterMovementComponent, in which case you need to tell that controller to freeze the character.  
It may be using some other MovementComponent (projectile, vehicle, …)  
It may be being animated by a level sequence.

Each of those need a different mechanism to “freeze” the actor, because they each move the actor in a different way. So, for your gameplay need, you can either make each of the movement methods that matter to you, know about this kind of freezing trigger, OR you can make your freezing triger, know about each movement method, and configure it appropriately.

---

<div class="post-metadata">

**Author:** ![StrUng1132](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@StrUng1132](https://forums.unrealengine.com/u/StrUng1132)\
**Post date:** [May 1, 2022, 6:34pm UTC](https://forums.unrealengine.com/t/how-do-i-lock-an-actor-in-place-with-c/545528/5 "2022-05-01T18:34:25Z")

</div>

Thank you very much, I forgot that “SetSimulatePhysics(false)” existed. The actor now stays in the location and doesn’t move anymore.
