So I am trying to create a locking mechanism.
Here is a picture of it.
Essentially, when it is in this position, http://imgur.com/a/o6tnE I want the square vertical peg to NOT be able to rotate on the plane parallel because if this was a real object, the peg is restricted on all sides by the hole it is stuck in.
However, in this case http://imgur.com/a/lfFQa that clearly doesn't work out because objects can overlap.
The only time it should be able to rotate freely is when the peg is above the hole as shown here: http://imgur.com/a/sGrFd
Is there a way to mate/relate everything so that I can freely move/rotate the peg in a circular path and know that the software itself will stop the objects at the right point if two parts collide?