I am using AlignPosition in PerAxis mode to move an object along X/Z axis and adjust the Y axis according to the floor so the object remains above ground. However, I am getting strange results with it going kind of like in a curve as the position is changed and also shakes while trying to reach it or stay in it.
Hello,
Thank you for the report. The path the part is taking is expected based on the implementation of the PerAxis mode of AlignPosition. When in PerAxis mode, the constraint is internally formulated as three separate constraints, one for each dimension. For each of these dimensions, we compute a separate target velocity based on the responsiveness that will bring the part closer to the target along that dimension. We chose this formulation for a few different reasons:
This behavior matches the behavior of the deprecated BodyPosition instance. Because replicating the functionality of this instance was one of the motivations for adding a “PerAxis” mode, we wanted to try to maintain similar behavior.
During testing, we noticed some non-intuitive behavior in some circumstances when we tried to use the same control logic that is used for “Magnitude” mode. This non-intuitive behavior occurred mainly when the part had some initial velocity and the force was specified in the world reference frame. In magnitude mode, the reference frame for the force doesn’t matter so we can use formulate the constraint such that it takes a more direct route to the target.
When using the PerAxis mode, using the same control logic from magnitude mode would cause the apparent responsiveness of the constraint to change if the allowed force was not well aligned with the target position. This theoretically could occur in a number of situations but is most likely when one of the components of the force is zero. Because this was a key application that we wanted to support, we chose control logic that ensured that responsiveness was consistent across different configuration.
All that said, the shaking is a bug. Based on some testing, it looks like it is associated with Adaptive timestepping. I am testing a fix now and we can hopefully deploy it soon. In the meantime, if you temporarily disable Adaptive timestepping, you should see the jittering go away.