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

Robot Volume 02 - Hybrid Rigging
You are here > Home > SimplyMaya Community Forums
Loading

Welcome to Simply Maya

Please Sign in or Sign up for an account

Member Login

Lost your password?

Not a member yet? Sign Up!

Old 27-12-2008, 08:55 PM   #1
bobsquish
Registered User
 
Join Date: Apr 2006
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
bobsquish is offline   Reply With Quote
Old 28-12-2008, 07:34 AM   #2
halfloaf
Subscriber
 
halfloaf's Avatar
 
Join Date: Mar 2008
Location: Bristol, UK.
Posts: 175
Thanks: 2
Thanked 9 Times in 8 Posts
Default 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.
halfloaf is offline   Reply With Quote
Old 28-12-2008, 10:41 AM   #3
bobsquish
Registered User
 
Join Date: Apr 2006
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi, thanks for your help but im very new to maya- how would i enter this command?

Thanks.
Ben
bobsquish is offline   Reply With Quote
Old 28-12-2008, 02:37 PM   #4
halfloaf
Subscriber
 
halfloaf's Avatar
 
Join Date: Mar 2008
Location: Bristol, UK.
Posts: 175
Thanks: 2
Thanked 9 Times in 8 Posts
Lightbulb 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 02:39 PM.
halfloaf is offline   Reply With Quote
Old 28-12-2008, 02:39 PM   #5
halfloaf
Subscriber
 
halfloaf's Avatar
 
Join Date: Mar 2008
Location: Bristol, UK.
Posts: 175
Thanks: 2
Thanked 9 Times in 8 Posts
Angry Image

Image attached!
Attached Thumbnails
 
halfloaf is offline   Reply With Quote
Old 28-12-2008, 03:16 PM   #6
bobsquish
Registered User
 
Join Date: Apr 2006
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thats Perfect - thanks sooo much!

bobsquish is offline   Reply With Quote
Old 28-12-2008, 04:48 PM   #7
bobsquish
Registered User
 
Join Date: Apr 2006
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
bobsquish is offline   Reply With Quote
Old 30-12-2008, 08:47 AM   #8
halfloaf
Subscriber
 
halfloaf's Avatar
 
Join Date: Mar 2008
Location: Bristol, UK.
Posts: 175
Thanks: 2
Thanked 9 Times in 8 Posts
Post 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
halfloaf is offline   Reply With Quote

A little bit about who we are
Links you might find useful
Catch up with SimplyMaya
SimplyMaya specialises in Maya tutorials. We offer over 1,000 individual Maya training videos, ranging from basic Maya tutorials through to intermediate Maya tutorials. Our tutorials are created by instructors with industry experience and are designed to get you up and running in Maya quickly without making it seem like hard work.

Copyright © 1999-2015 SimplyMaya - vBulletin® Copyright © 2000-2015, Jelsoft Enterprises Ltd.