Well, nevermind, I figured it out myself.
First off, when I tried to find the SetConstrainCompoents in C++, the autocomplete didn’t work at first, so I thought it didn’t exist. Turns out it does.
I checked the source code and noticed it does some initialization and uses some private variables that I didn’t do when I tried to do it in my own code:
So, I changed my code to this, and now everything works perfectly.