Constrain movement of an object within a defined area?

Wondering how to accomplish a certain animation task? Ask here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
Ahroo
Posts: 41
Joined: Sat Jun 11, 2011 7:53 pm

Constrain movement of an object within a defined area?

Post by Ahroo »

I have a plain, simple box. Inside it (on a separate layer) is a ball. I want the ball to be able to move about anywhere within the box, but not be able to "escape" the box. Think pinball machine, except that I don't need to automatically control the movement in any way (e.g. bouncing off the sides) - just the limits of where the ball can go. I will manually animate the ball, but thought it might make it easier if it could be set up so that the ball cannot move outside the box so I don't have to be as careful in the animation process (ultimately there will be multiple balls, controlled by one or more bones, so this could be a time saver in the long run if I can get it to work). Obviously, I cannot use masking because it will allow the ball to move beyond the perimeter of the box, just not show the part that is outside. I thought that perhaps there is some way I can utilize physics to accomplish this, but so far I have not been able to figure it out or find any previous topics on the forum about this. Any suggestions (using physics or any other solution) to restrict the movement of the ball to within the confines of the box?

Thanks!
User avatar
slowtiger
Posts: 6240
Joined: Thu Feb 16, 2006 6:53 pm
Location: Berlin, Germany
Contact:

Re: Constrain movement of an object within a defined area?

Post by slowtiger »

What about binding that ball to a very long bone with small angle constraints which is the perpendicular child of another very long bone also with small angle constraints? It will not be a perfect rectangle, but good enough.
AS 9.5 MacPro Quadcore 3GHz 16GB OS 10.6.8 Quicktime 7.6.6
AS 11 MacPro 12core 3GHz 32GB OS 10.11 Quicktime 10.7.3
Moho 13.5 iMac Quadcore 2,9GHz 16GB OS 10.15

Moho 14.1 Mac Mini Plus OS 13.5
Ahroo
Posts: 41
Joined: Sat Jun 11, 2011 7:53 pm

Re: Constrain movement of an object within a defined area?

Post by Ahroo »

Thanks for your reply, Slowtiger. I did think about using bone constraints (and have been playing around with this a bit, experimenting with various constraint and bone length settings), and it does help some. Now I'm trying a ball inside a circle, and the double, constrained bone technique works to some degree, but there are still areas where the ball either extends beyond the outer circle, or never quite makes it to the edge. I just don't know if animating the bones in this manner works any easier/better/faster than just manually moving the ball, so I'm still looking for another option to restrict where the ball can go, if anyone has any ideas.
Ahroo
Posts: 41
Joined: Sat Jun 11, 2011 7:53 pm

Re: Constrain movement of an object within a defined area?

Post by Ahroo »

Thanks, Wes - that's amazing and exactly what I was trying to accomplish! I don't yet understand HOW it works, but I will be studying your file (it obviously has something to do with the angle control bone, which I've never used before, and the IK stretching, so I'll need to do some research and experimenting with those). I appreciate you taking the time to work on this!

Laura
User avatar
synthsin75
Posts: 10254
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Constrain movement of an object within a defined area?

Post by synthsin75 »

Ahroo wrote:Thanks, Wes - that's amazing and exactly what I was trying to accomplish! I don't yet understand HOW it works, but I will be studying your file (it obviously has something to do with the angle control bone, which I've never used before, and the IK stretching, so I'll need to do some research and experimenting with those). I appreciate you taking the time to work on this!

Laura
The angle control just keeps the point-bound ball from rotating as its parent bone follows the target bone. The big bone (B1) has 100 maximum IK stretching and is scaled to 0.01 on frame one. This is what allows it to shrink as the target gets closer. It's the trick Victor used here: viewtopic.php?p=149734#p149734
Ahroo
Posts: 41
Joined: Sat Jun 11, 2011 7:53 pm

Re: Constrain movement of an object within a defined area?

Post by Ahroo »

Still a bit baffled, but I'm working with it and will eventually figure it out. Thanks again!!
Post Reply