# Constraint drives not switching on in 4.13

**URL:** <https://forums.unrealengine.com/t/constraint-drives-not-switching-on-in-4-13/369343>\
**Category:** World Creation\
**Tags:** UE4-13, unreal-engine, Physics, bug-report, question\
**Created:** [September 4, 2016, 1:44pm UTC](https://forums.unrealengine.com/t/constraint-drives-not-switching-on-in-4-13/369343 "2016-09-04T13:44:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kamrann](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kamrann](https://forums.unrealengine.com/u/kamrann)\
**Post date:** [September 4, 2016, 1:44pm UTC](https://forums.unrealengine.com/t/constraint-drives-not-switching-on-in-4-13/369343/1 "2016-09-04T13:44:20Z")

</div>

I’ve just upgraded to 4.13, which involved a lot of changes to code that set up constraints programmatically. It now compiles and everything seems to work, except where I was enabling drives.

Am I misunderstanding how it works, or are [these lines](https://github.com/EpicGames/UnrealEngine/blob/master/Engine/Source/Runtime/Engine/Private/PhysicsEngine/ConstraintDrives.cpp#L104-L114) incorrect?

```
SwingDrive.bEnablePositionDrive &= InEnableSwingDrive;
TwistDrive.bEnablePositionDrive &= InEnableSwingDrive;

```

Why the `&=`? It is preventing me from enabling a drive in code.

Edit: Okay it looks to me like this code is rife with errors. The code above is using `InEnableSwingDrive` for the twist drive too and ignoring the twist argument. More than that, [these booleans don’t even appear to be getting used when configuring the PhysX objects!](https://github.com/EpicGames/UnrealEngine/blob/master/Engine/Source/Runtime/Engine/Private/PhysicsEngine/ConstraintDrives.cpp#L55-L88)

Edit2: They are used, but in a very confusing way. The `if(bDriveEnabled)` block is being run even for drives that are fully disabled, but then setting up those drives with 0 spring/damping.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_61b4a355](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_61b4a355](https://forums.unrealengine.com/u/anonymous_user_61b4a355)\
**Post date:** [September 6, 2016, 8:42pm UTC](https://forums.unrealengine.com/t/constraint-drives-not-switching-on-in-4-13/369343/2 "2016-09-06T20:42:38Z")

</div>

Hey kamrann,

Thanks for the report.

I can’t tell you why the programmer used &= or why InEnableTwistDrive is ignored in both functions but I have created a issue for it. You can follow it here:

[https://issues.unrealengine.com/issue/UE-35634](https://issues.unrealengine.com/issue/UE-35634)

---

<div class="post-metadata">

**Author:** ![dupe\_Ori\_Cohen](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@dupe\_Ori\_Cohen](https://forums.unrealengine.com/u/dupe_Ori_Cohen)\
**Post date:** [September 20, 2016, 1:53pm UTC](https://forums.unrealengine.com/t/constraint-drives-not-switching-on-in-4-13/369343/3 "2016-09-20T13:53:14Z")

</div>

Hey, thanks for posting this. As you mentioned this was part of a huge refactor and it was simply a copy and paste error ☹

The &= should also be an = as you say. I’ve fixed it for 4.14 - please let me know if there’s any other issues with constraints.

Thanks!

---

<div class="post-metadata">

**Author:** ![kamrann](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kamrann](https://forums.unrealengine.com/u/kamrann)\
**Post date:** [September 20, 2016, 2:17pm UTC](https://forums.unrealengine.com/t/constraint-drives-not-switching-on-in-4-13/369343/4 "2016-09-20T14:17:43Z")

</div>

No problem Ori. I’ve had to revert the project to 4.12 so didn’t do any further testing after encountering this issue. However first impressions were that everything else seemed to be working as expected.

Regarding my second edit above, does PhysX itself simply not make a distinction between disabled drives and drives with zero strength? My assumption was that it would be inefficient to have every single joint have a zero strength drive associated with it, but a brief look at the PhysX side suggested that this is indeed how it works.

Oh and while I’m here - `UPhysicsConstraintComponent::SetContraintReferenceFrame` is documented saying that changes will take effect in `InitConstraint` if the constraint is not yet active when called. This is what I’d expect would happen, however I’m pretty sure that the frame just gets overwritten at that point by that calculated from the transformations of the bodies with respect to the constraint component. I personally find it more intuitive to configure the reference frames manually in the same way as in PhysX, so it would be helpful if the above method did behave as suggested in the documentation.

Cheers.
