Page 1 of 1

### Issue moving objects that are constrained together.

Posted: Tue Apr 27, 2021 6:50 pm
Hello, the issue I am having has to do with a dynamic object being constrained with a fixed constraint to a kinematic object that are being moved quite drastically as a result of an event in the game I am making. When this event occurs the kinematic object is move from around a Y of -5.f to a Y of 1.f, and the dynamic object that is constrained to the other object is flung up into the air.

My assumption is that because of how far the kinematic object moves, the constraint is acting like a rubber band pulling the dynamic object to the kinematic, and then flinging it further. I have searched through the forum and tried many of different ways to prevent this, manually setting the location for some time, changing the parameters on the constraint, setting the velocity on both the objects to 0 over multiple frames, and more. None of these seem to stop the dynamic object from either flying into the air before returning, appearing where it's supposed to be but in the wrong orientation and then rotating back to where it should be, or slowly moving from the -5 to the y of 1.

I have thought of a few work arounds so I can at least continue with other things for now, but all of them prevent the dynamic object from interacting with other objects in a natural way, and I was hoping someone may have some suggestions how how to handle the dynamic object being flung around.

### Re: Issue moving objects that are constrained together.

Posted: Tue Apr 27, 2021 7:58 pm
Here are some ideas:

(1) Don't teleport the kinematic object in one step. Instead animate it from A to B quickly, but over several steps. This will give the constraint time to pull the dynamic object to its new location in a smoother way.

(2) If you must teleport the kinematic object in one step, then also teleport the dynamic object such that it maintains its kinematic-object-local offset.

(3) Maybe you don't want a stiff constraint when the kinematic object is teleported. Dynamically soften the constraint to slow its response on teleport and then set it stiff again after things have settled.

(4) If none of those work for you then: I would ask: "Are you sure you really want a constraint there? Maybe you should be doing something else more bespoke, like a custom smart Action or a series of hacky workarounds as final solution."

### Re: Issue moving objects that are constrained together.

Posted: Tue Apr 27, 2021 8:10 pm
Unfortunately, I do need to do it in one step, and have been teleporting the dynamic object at the same time, this is all happening during a collision callback method during the step simulation. The problem occurs during the following simulation step, which really doesn't make sense since I also cleared the velocity one those frames(for testing purposes).

I do have one hacky work around, but I think my main issue with being bothered by the fact that even teleporting both objects and clearing the velocities don't seem to affect it.

Does the constraint itself hold onto any notion of velocity or force that I might have missed and need to clear?

### Re: Issue moving objects that are constrained together.

Posted: Tue Apr 27, 2021 8:52 pm
Ah... it happens in the middle of the step? Maybe try teleporting things right before the next step. That is: set a bool variable teleportBeforeNextStep in the collision callback and outside the step: when teleportBeforeNextStep is true: do the teleport outside of the step itself and set teleportBeforeNextStep back to false.

Really, I'm guessing here. Dunno what kind of state is stored in the constraint solver during the step.