# Applying constraints to a a rigidbody/physics enabled component

**URL:** <https://forums.unrealengine.com/t/applying-constraints-to-a-a-rigidbody-physics-enabled-component/345482>\
**Category:** World Creation\
**Tags:** Constraints, unreal-engine, CPP, question\
**Created:** [January 26, 2016, 11:37pm UTC](https://forums.unrealengine.com/t/applying-constraints-to-a-a-rigidbody-physics-enabled-component/345482 "2016-01-26T23:37:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Graylord](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Graylord](https://forums.unrealengine.com/u/Graylord)\
**Post date:** [January 26, 2016, 11:37pm UTC](https://forums.unrealengine.com/t/applying-constraints-to-a-a-rigidbody-physics-enabled-component/345482/1 "2016-01-26T23:37:40Z")

</div>

I’m basically looking to do [Applying 2D Physics | Unreal Engine Documentation](https://docs.unrealengine.com/latest/INT/Engine/Paper2D/HowTo/Physics/index.html) in C++

```
CollisionComponent->SetSimulatePhysics(true);

```

How can I apply constraints? I haven’t found any good examples yet.

---

<div class="post-metadata">

**Author:** ![Daes](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Daes](https://forums.unrealengine.com/u/Daes)\
**Post date:** [January 27, 2016, 3:15am UTC](https://forums.unrealengine.com/t/applying-constraints-to-a-a-rigidbody-physics-enabled-component/345482/2 "2016-01-27T03:15:23Z")

</div>

There is a tutorial on creating dynamic constraint on the wiki:

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

You will find in it informations about the classes you need : UPhysicsConstraintComponent - FConstraintInstance

Basic informations on constraint there: [Physics Constraint Component User Guide | Unreal Engine Documentation](https://docs.unrealengine.com/latest/INT/Engine/Physics/Constraints/ConstraintsBlueprints/)

But, to be honest, i am battling with it a little, at least for initialization of physically based aactor.  
Defered Attachment is the key, in this particular case.

For physics attached component, i used:

```
component->AttachParent = parent ; // Deferred attachment

```

instead of

```
component->AttachTo(parent); // direct attachment

```

Cheers
