Use new location when using constraints?

Is there a way to have an object use a new location if a constraint causes the object to move?

So lets say I have an empty at zero, with no parents.
I add a limit distance constraint to another empty also at zero and set the distance to zero.
So far, so good, the empty now ensures it is never more than 1m away from the other object. But the object always tried to get back to zero, because that’s it’s location.

I’d like to have it’s location change. So if the constraint causes it to move from 0,0,0 to 1,0,0 then instead of it’s location still being 0,0,0 I want it to be 1,0,0. And that location wouldn’t change until the limit forced it into a new position.
I “thought” that’s what the “Affect Transform” checkbox did, but I guess not.

So I’m looking for some sort of way to constrain an object where it evaluates it’s current position, and that changes it’s actual transform. If it’s something like a limit distance constraint, it wouldn’t do anything to the object if the target object is moving around the limited object if the target object isn’t moving more than the limited distance. But if it does, then the other object would follow behind until the other object stopped. As the object gets forced into new position, I would want the object’s transform to change as well, otherwise it always tries to get back to it’s original position.

This Could be something super basic. I have no idea. Consider me completely new to rigging for this problem.

This sounds like something for which you need animation nodes or rigid body constraints, because you have a dynamic state in your system: the past movement influences the behavior at the current frame.

1 Like

I was afraid of that. Animation nodes might be a good solution since that’s basically just visual programming with some built in functions.

To get by for now, I created a single hair particle and used particle instancer on another object to put it at the end of the hair. I just have to animate my object in a little circle first if I want that object to actually start at zero so that the hair’s end point is the same as it’s base point to start.
The thing I don’t like about doing that, is since it’s a particle system, I have to be sure to cache all the animation before rendering. I’m not so sure animation nodes would be much different though.

I just aske because I noticed Maya works different. I was watching a video and the guy constrained a dummy to a circle path with an object constraint. And every time he moved the circle, the dummy moved along the path based on maybe the motion vector of the circle. But in blender, it sticks to the circle, but always tries put itself back to the position recorded in the transform.

It seems like this post might be the right direction as well, but it is Old, and the very last post said that it’s depricated and to use something else: Execute custom script when object is moved - #9 by batFINGER
Because, yes, doing it on frame change would work for an animation, but it’s nice to also just grab something and see what’s going to happen, so I’d want to evaluate on an object being moved as well.
With animation nodes at least you can set it to always run, or run on frame change. So just have it set to always when you’re messing with that animation. Then turn it back to on frame change.

So I guess I could just use animation nodes to evaluate an object’s current world position, then make it’s current transform match that position. The limit controller should still work, I think.

In the end I just want one object to drag behind another. But if the other object moves over top of that object, to not move the dragged object. And I’m trying to learn the most effective way of doing that.

Animation nodes made quick work of that. And if you want a bunch of objects to “drag” then you just throw them all in a collection and create a subprogram loop that looks something like this:

But realy the basic is just get the Object Matrix Input for each object, decompose that, then plug the translation into the object transforms output.
In other words, write the actual world location to the object location.

This should work great for any time you use a constraint. I actually wish this was the default. If I wanted it to constantly try and target back to it’s starting position, I’d have added another constraint :wink:

thanks for the help. I’m sure I’ll use this trick frequently.

1 Like