## Maya Training

Introduction to Hard Surface Modeling

## Maya Training

Interiors and Furniture Vol 1 & 2 - Modeling & Cloth

## Maya Training

Shading, Lighting and Rendering the Bedroom in MR

## Maya Training

Robot volume one - Modeling with animation in mind

## Maya Training

Spach-Alspaugh House the complete courseware

## Maya Training

Burt The Cartoon Dinosaur Vol 01 - Modeling

## New Maya Training

Batman by Jason Edwards
You are here > Home > SimplyMaya Community Forums

# Welcome to Simply Maya

 Simply Maya User Community - Maya Tutorials constraining object to midpoint
 Register FAQ Members List Calendar Mark Forums Read

 27-12-2008, 07:55 PM #1 bobsquish Registered User   Join Date: Apr 2006 Posts: 26 Thanks: 0 Thanked 0 Times in 0 Posts constraining object to midpoint Hey, I have two objects which have aim constraints so they point towards each other and another one in the middle which does the same, however, i want this object to always be in at the midpoint of the first two objects as they move apart. Thanks, ben
 28-12-2008, 06:34 AM #2 halfloaf Subscriber     Join Date: Mar 2008 Location: Bristol, UK. Posts: 175 Thanks: 2 Thanked 9 Times in 8 Posts Constraints Hiya, If I understand you correctly, the best thing to do to get the centre object to always be in the middle of the outer objects would be to create an expression. Something along the lines where; Object Left = "object_L" Object Right = "object_R" Object Centre = "object_C" These are just descriptors...your expression would be... object_C.tx=(object_L.tx + object_R.tx)/2; object_C.ty=(object_L.ty + object_R.ty)/2; object_C.tz=(object_L.tz + object_R.tz)/2; What you're doing is telling object_C (your centre object) to inherit the average value of the translate values (tx, ty & tz) of the left and right objects. Hope that helps! -Jacques.
 28-12-2008, 09:41 AM #3 bobsquish Registered User   Join Date: Apr 2006 Posts: 26 Thanks: 0 Thanked 0 Times in 0 Posts Hi, thanks for your help but im very new to maya- how would i enter this command? Thanks. Ben
 28-12-2008, 01:37 PM #4 halfloaf Subscriber     Join Date: Mar 2008 Location: Bristol, UK. Posts: 175 Thanks: 2 Thanked 9 Times in 8 Posts Expression editor Hiya, No probs. You need to go to "Window->Animation Editors->Expression Editor" Next, give the expression a name in the "Expression Name" field and click "New Expression" Type in (or copy an paste) the expression in the "Expression" box...and click "Create" You need to change the "Object_L" etc. for whatever your object is called. So, if you have say two spaceships called "ship1" and "ship2" with a planet in the middle, your first part of the expression would look something like... planet.tx=(ship1.tx + ship2.tx)/2; same goes for translate y planet.ty=(ship1.ty + ship2.ty)/2; Move one of the outside objects and your centre object will more with it. I've attached a snapshot. -Jacques Last edited by halfloaf : 28-12-2008 at 01:39 PM.
 28-12-2008, 01:39 PM #5 halfloaf Subscriber     Join Date: Mar 2008 Location: Bristol, UK. Posts: 175 Thanks: 2 Thanked 9 Times in 8 Posts Image Image attached! Attached Thumbnails
 28-12-2008, 02:16 PM #6 bobsquish Registered User   Join Date: Apr 2006 Posts: 26 Thanks: 0 Thanked 0 Times in 0 Posts Thats Perfect - thanks sooo much!
 28-12-2008, 03:48 PM #7 bobsquish Registered User   Join Date: Apr 2006 Posts: 26 Thanks: 0 Thanked 0 Times in 0 Posts Actually - Ive tried on another piece and the mid piece goes the opposite direction to what i want when i move one of the outer objects- ive looked in the channel box and its translate attributes are the opposite of everything else, how can i change this? Thanks, Ben
 30-12-2008, 07:47 AM #8 halfloaf Subscriber     Join Date: Mar 2008 Location: Bristol, UK. Posts: 175 Thanks: 2 Thanked 9 Times in 8 Posts Hmm Hmm, Can you post an image? Also, you may find that you have frozen transformations on two of the objects and not the other? Are you working with global or local axis points... I have a suspicion it's the freeze transformations problem... delete the expression, freeze transformation on the objects and try creating the expression again. -J

A little bit about who we are