Okay, so I am trying to create a simple self-reconfigurable robotic simulator in UE4. I have the distributed control, message passing, etc. working, but I am somewhat stuck on the dynamic constraints. I have written a self-reconfigurable simulator using OpenGL, PhysX, and OpenFrameworks, but I would love to implement this in UE4 to take advantage of its vast array of features (drag and drop, easy environment creation, etc.).
I have a lot of experience with using PhysX directly, and I can use PhysX directly in my other simulator to create fixed joints that “pull” the constrained components together automatically. PhysX does this automatically using low level flags and appropriate relative positions/orientations of the bodies to be constrained. I am trying to achieve something similar in UE4.
I am attaching a picture of the situation I have and what I would like to have after the correction. I have two robotic modules (in the simplest case) that need to dock together during runtime
. These are autonomous robots, so it is impossible that they will ever line their docks up exactly such that there is zero error. I am able to spawn a physics constraint (fixed joint) to hold them together and weld them together, but the difference in position and orientation remains, even when the constraint is applied. They are simply stuck together as shown in the picture. (Note that the error in this picture is exaggerated. It is not usually this much.) This is problematic, because we have physical mechanisms on the real hardware that guide the docks into the correct place. So, I need to fix the position and orientation error during runtime to “dock” the modules together flush.
My question is whether or not anyone knows if something similar can be achieved in UE4? I read about collision bounds and overlaps and didn’t know if maybe I could detect an overlap at a certain tolerance and use that somehow. I could manually move the modules, but, in general, each side could have more modules connected, meaning all of them would have to be relocated and reoriented, which would be quite tedious. I didn’t know if anyone else knew of a simpler way to handle this?
Ok, so based on rantrod’s help, the following code worked. In summary, I had to use AttachRootComponentTo in order to line up the docks, then I used a physics constraint actor to actually make the connection. It should be enough to weld the elements together once they are lined up, but that part I still can’t get to work. Thanks!: