# Setup angular motors in c++

**URL:** <https://forums.unrealengine.com/t/setup-angular-motors-in-c/378714>\
**Category:** World Creation\
**Tags:** physics-constraint, unreal-engine, CPP, question\
**Created:** [December 8, 2016, 4:27pm UTC](https://forums.unrealengine.com/t/setup-angular-motors-in-c/378714 "2016-12-08T16:27:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon4801053](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anon4801053](https://forums.unrealengine.com/u/anon4801053)\
**Post date:** [December 8, 2016, 4:27pm UTC](https://forums.unrealengine.com/t/setup-angular-motors-in-c/378714/1 "2016-12-08T16:27:05Z")

</div>

Hi,

in my project I need to create `PhysicsConstraints` and setup their angular motors during runtime in C++. Since I also need to lock certain angular motions I can’t use SLERP and have to switch to Twist and Swing. However the option to set the `AngularDriveMode` of a `FConstraintInstance` is deprecated in the current version and doesn’t work anymore.

![117874-angulardrivemode.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/8/e/b8e4c4d45df5efa0be39b7ea982277b3f4f3f6b0.png)

There doesn’t seem to be any alternative to set the angular drive mode in C++.

This is my code where I create my constraint and set all the properties

```
// Set the limitations
FConstraintInstance ConstraintInstance;
ConstraintInstance.SetDisableCollision(true);
ConstraintInstance.SetLinearXLimit(ELinearConstraintMotion::LCM_Locked, 0);
ConstraintInstance.SetLinearYLimit(ELinearConstraintMotion::LCM_Locked, 0);
ConstraintInstance.SetLinearZLimit(ELinearConstraintMotion::LCM_Locked, 0);
ConstraintInstance.SetAngularSwing1Limit(EAngularConstraintMotion::ACM_Free, 0);
ConstraintInstance.SetAngularSwing2Limit(EAngularConstraintMotion::ACM_Free, 0);
ConstraintInstance.SetAngularTwistLimit(EAngularConstraintMotion::ACM_Locked, 0);
ConstraintInstance.AngularRotationOffset = FRotator(0, 0, 0);
ConstraintInstance.AngularDriveMode_DEPRECATED = EAngularDriveMode::TwistAndSwing; // Doesn't work since it's deprecated

// Create the respective joint
UPhysicsConstraintComponent* Constraint;
Constraint = NewObject<UPhysicsConstraintComponent>(RootComponent);
Constraint->RegisterComponent();

// Set the properties of the joint and connect the two meshes
Constraint->ApplyWorldOffset(FVector(0, 0, 0), false);
Constraint->ConstraintInstance = ConstraintInstance;
Constraint->AttachToComponent(myMesh, FAttachmentTransformRules(EAttachmentRule::KeepRelative, false));
Constraint->SetRelativeLocation(FVector(0.0f, 0.0f, 0.0f));
Constraint->ConstraintActor1 = this;
Constraint->ConstraintActor2 = this;
Constraint->SetAngularVelocityDrive(true, true);
Constraint->SetAngularVelocityTarget(FVector(10.0f, 10.0f, 10.0f));
Constraint->SetConstrainedComponents(parent->MeshComponent, NAME_None, myMesh, NAME_None);

```

The angular drive mode always stays on SLERP which I can’t use if I lock any angular motion.

![117875-angularmotor.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/1/4/e1424c8755826ace0641d60f7125541d2c12820a.png)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_e729f54e](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e729f54e](https://forums.unrealengine.com/u/anonymous_user_e729f54e)\
**Post date:** [December 8, 2016, 7:33pm UTC](https://forums.unrealengine.com/t/setup-angular-motors-in-c/378714/2 "2016-12-08T19:33:05Z")

</div>

Hello ASchoenfeld,

After doing a bit of digging I was able to find that this variable has been deprecated without documentation. I have written up a report and I have submitted it to the developers for further consideration. I have also provided a link to the public tracker. Please feel free to use the link provided for future updates.

Link: [Unreal Engine Issues and Bug Tracker (UE-39516)](https://issues.unrealengine.com/issue/UE-39516)

Make it a great day

---

<div class="post-metadata">

**Author:** ![terids](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@terids](https://forums.unrealengine.com/u/terids)\
**Post date:** [March 14, 2017, 5:40pm UTC](https://forums.unrealengine.com/t/setup-angular-motors-in-c/378714/3 "2017-03-14T17:40:52Z")

</div>

It appears a lot of this functionality got split up into other files.

This is how I got it to work…

```
ConstraintInstance.ProfileInstance.AngularDrive.AngularDriveMode = EAngularDriveMode::TwistAndSwing;
```

---

<div class="post-metadata">

**Author:** ![anon4801053](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anon4801053](https://forums.unrealengine.com/u/anon4801053)\
**Post date:** [March 23, 2017, 9:00pm UTC](https://forums.unrealengine.com/t/setup-angular-motors-in-c/378714/4 "2017-03-23T21:00:08Z")

</div>

This is exactly what I was looking for. Thank you very much.
