Multiple targets in a look-at controller

Multiple targets in a look-at controller

Peter_MH
Contributor Contributor
1,346 Views
9 Replies
Message 1 of 10

Multiple targets in a look-at controller

Peter_MH
Contributor
Contributor

I'm trying to rig a simple eyeball look-at constraint that uses two distinct targets.  I want the eyeball to generally follow the main target but then occasionally shift/translate to target B.

I want a single slider button to control the look-at direction/target weighting.  The button would start with target A and then when translated, the look-at weighting would transition to target B.

But I'm doing something wrong.  Something that seems so easy in concept is failing me; my parameter-wiring results produce a "pop" during the transition from target A to target B.  Target A weighting starts at 100 while Target B starts at 0.

If I move the slider button up 1 unit, I want Target A look-at weighting to transition to 0 while Target B look-at weighting goes to 100.

I'm missing something obvious because I'm getting a pop during the transition.

I've looked around online for guides or examples to this particular setup but can't find anything.  Most eye setups are routinely locked onto just one target.

Can anyone here provide a solution?

I've attached a file with a point helper using a look-at controller and two separate targets, along with the button slider control.  No wiring applied between the controller and the button.

Thanks, I'd appreciate anything that makes me feel less stupid.

 

0 Likes
Accepted solutions (1)
1,347 Views
9 Replies
Replies (9)
Message 2 of 10

leeminardi
Mentor
Mentor
Accepted solution

Here's a method using a Script Controller to do what I think you want although in a much different manner.

I created a point named TargetPoint with a script controller that positions it as a function of the location of the two circles AND the position of your object CTRL_button. The lookat constraint looks at this point. If the z coordinate of CTRL_button is equal to or less than zero then A is looked at (the point is at A). If the z coordinate of CTRL_button is equal to or greater than 1.0 then B is looked at. If the z coordinate of CTRL_button is between 0.0 and 1 then the TargetPoint is proportionally positioned between A and B.

This approached could be tweaked to better fit your needs if appropriate. 

It may be possible to adjust the weighing factors but I was more comfortable with this approach.

sc01.JPG

 

lee.minardi
0 Likes
Message 3 of 10

Peter_MH
Contributor
Contributor

Thanks Lee.

 

I "pulled up" to the idea of using a script controller and then did a U-turn and went back to banging my head against the look-at controller weighting and parameter wiring.  I'm not as experienced with script controllers as I should be.

 

Until now!  I'm going to dive into the topic and study your solution.  Your idea is a solid stride towards what I'm seeking.

 

Thanks again, you've provided some great help to me.

 

 

0 Likes
Message 4 of 10

leeminardi
Mentor
Mentor

You're welcome.  Let me know if you have any questions.

 

Note, if the "eyes" are linked to other objects the script controller must include that in expressions.  I found the best way to handle this is by multiplying the transforms from child to parent.  You may want to use a Custom Attribute controller instead of the Z position of an object to adjust the weighing of the lookat constraint. If you have a sample model you would like to try this with please post it and I will try rigging it.   

 

lee.minardi
0 Likes
Message 5 of 10

Anonymous
Not applicable

Is there something that prevents you from simply using Reaction Manager?

0 Likes
Message 6 of 10

leeminardi
Mentor
Mentor

@Anonymous  Thanks for the suggestion. I was not aware of the Reaction Manager.  It looks interesting and may have promise.  From a brief read it isn't clear if it supports multiple "masters" i.e., the two targets and the controller for how to mix attention between the two.   I need to familiarize myself with this tool.

Lee

 

lee.minardi
0 Likes
Message 7 of 10

Anonymous
Not applicable

@leeminardi wrote:

@Anonymous  Thanks for the suggestion. I was not aware of the Reaction Manager.  It looks interesting and may have promise.  From a brief read it isn't clear if it supports multiple "masters" i.e., the two targets and the controller for how to mix attention between the two.   I need to familiarize myself with this tool.

Lee

 


A single master can control multiple states of multiple slaves. I thought that would be the requirement here.

0 Likes
Message 8 of 10

Peter_MH
Contributor
Contributor

Yep.

 

Reaction Manager seems more appropriate for this problem.  I just rigged up my test successfully using Reaction Manager (file attached).

 

By more appropriate, I mean a little easier.  Lee's Script Controller suggestion looks like far more capable of granular control if needed but in this case, my problem is pretty one-dimensional.  That's partly why I was feeling so stupid prior to posting my question; there's just gotta be some way inside Max to do something so simple.

 

I'm not sure why I couldn't think of Reaction Manager.  I've done some tests with it a long time ago and then forgot about it.  Maybe reading about people having problems with max files losing their reaction manager setups helped push the concept into the back of my mind.

 

Thanks aon.914858227.  A great benefit of this forum is the multiple solutions proposed.  I had spent yesterday learning Script Controllers via Lee's suggestion (and watching some of his hang-gliding videos on Youtube.com) and my eye-rig file was looking heading towards completion last night.

 

And then this morning...a slap to the forehead.

 

Thanks again.

 

 

0 Likes
Message 9 of 10

leeminardi
Mentor
Mentor

@Anonymous would you please post a copy of your file that used Reaction Manager in a 2018 or earlier format.  I would like to look at it.  Thank you.

 

@Peter_MH I've attached what I think is a cleaner version of my original solution that used a script controller.  In this version I created a custom attribute for setting the amount of blend between the two targets.  Just select TargetPoint and then open the Modify tab to the the custom Attribute "AB Blend". Slide it all the way to the left and the target is coincident with A, to the right it's coincident with B and inbetween the target is inbetween.  Since the range of values for the attribute is 0 to 1 there's no need for the if statement from  my original solution.  In addition, I think  it is much easier to control the blend with the attribute rather than the z position of CTRL_Button.  Note, I rigged this in my own file.

blendAB.JPG

There are only three expressions:

 

 

d = distance TargetA TargetB
v = normalize (TargetB - TargetA)  -- unit vector from A to B 
p = TargetA + BlendAB * d * v

 p is a vector that goes from 0,0,0 to targetA and then on by a distance d * (the value of BlendAB) in the direction of v.  

 

Move A or B around and also adjust AB Blend.  I've used two dummy object to represent the eyes that are linked to a box named head.  You can move head around as well.

 

 

lee.minardi
0 Likes
Message 10 of 10

Peter_MH
Contributor
Contributor

Thanks for continuing to look at this Lee.

 

Attached is the Reaction Manager-rigged test file, in max2016 format.

 

I'm not sure if I'm doing something incorrectly with Reaction Manager (after watching some tutorials) but I'm getting a tiny bit of volatility when going through the process in my main character file.  The button starts as default at the top of the slider and everything is fine.  But when you slide it down, the look-at interpolation moving to target B goes fine until right at the very end when the look-at controllers suddenly pop the eyeballs down and into a cross-eyed angle.  I can work around it for the moment but eventually I'd like it to work properly.

 

In Reaction Manager, setting it up creates more than the two "states" that I clearly need so I've deleted the extras.  But maybe I shouldn't delete them.  More exploration needed.

 

I may swing back to your refined scripting option.  I'll have to study it some more.

 

Thanks again.

 

 

0 Likes