SimplyMaya Forums

Welcome to the forum, feel free to ask questions here.

Home / forum / Lounges / Maya Basics & Newbie Lounge / constraining object to midpoint
Register FAQ Members List Calendar Mark Forums Read

New Thread
 
Thread Tools
Old 27-12-2008, 07: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, 06:34 AM   #2
halfloaf
Lifetime Member
 
halfloaf's Avatar
 
Join Date: Mar 2008
Location: Bristol, UK.
Posts: 191
Thanks: 3
Thanked 11 Times in 10 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, 09: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, 01:37 PM   #4
halfloaf
Lifetime Member
 
halfloaf's Avatar
 
Join Date: Mar 2008
Location: Bristol, UK.
Posts: 191
Thanks: 3
Thanked 11 Times in 10 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 01:39 PM.
halfloaf is offline   Reply With Quote
Old 28-12-2008, 01:39 PM   #5
halfloaf
Lifetime Member
 
halfloaf's Avatar
 
Join Date: Mar 2008
Location: Bristol, UK.
Posts: 191
Thanks: 3
Thanked 11 Times in 10 Posts
Angry Image

Image attached!
Attached Thumbnails
Click image for larger version

Name:	snap1.jpg
Views:	86
Size:	75.4 KB
ID:	41126  
halfloaf is offline   Reply With Quote
Old 28-12-2008, 02: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, 03: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, 07:47 AM   #8
halfloaf
Lifetime Member
 
halfloaf's Avatar
 
Join Date: Mar 2008
Location: Bristol, UK.
Posts: 191
Thanks: 3
Thanked 11 Times in 10 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
New Thread

« Previous Thread | Next Thread »

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

1 Month

$34

Month-to-month billing
$34/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
 
 

3 months

$87

Billing every 3 months
$29/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $5 per month or $15 in total compared to monthly billing with this package.

12 months

$288

Billing every 12 months
$24/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $10 per month or $120 in total compared to monthly billing with this package.

Your plan will automatically renew. You can cancel at any time via your PayPal account to avoid being charged again.

You can view the FAQ on our video plans here. You can contact us directly here. By clicking one of the buttons above, you agree to our Terms and Privacy Policy.