# keeping an object between 2 others with nodes?

#### marchermitte

##### Member
Hello!
I'm trying to setup something that seemed extremely easy at first look (easy with expression et least)
Like keeping the hips between the two feet for instance.
Tried with the item infos nodes, distance from / to, dividing the result by 2, splitting the vectors to get the x / y and z separately... nothing works.
All I'm getting is the center mesh to move toward the last moving of the other objects.

Thank you

#### Sensei

##### TrueArt Support
Where do you want it to make?
In Displacement Node Editor?
or
In Motion Node Editor?

Displacement Node Editor is working with deltas, relative offsets, from current position of vertex, to new position of vertex.
So you can't just take some item position, and plug to Displacement Input. Have to make them relative first.

ps. Often made mistake is forgetting about double clicking Item Info node to open panel and picking up item from drop-down list.
You have to use World Position, World Spot,
not Object coord space.

ps2. Show screen-shot of your node setup to discuss where is issue.. As always.

Last edited:

#### marchermitte

##### Member
I thought of using the node motion for that...
Here is a screen from my lame attempts...

#### Sensei

##### TrueArt Support
To calculate middle point between two vectors, positions of items,
take World Position (!), then add vectors together, Math > Vector > Add,
then use Math > Vector > Scale 0.5 (50%) (for example).

or use Tools > Mixer 50% opacity (don't bother that they're colors, not vectors, it's the same).

#### marchermitte

##### Member
Ah ah! Works like a charm... of course, dividing by 2 or multiplying by 0.5 isn't going to split the vector by two.
Thank you for sharing your knowledge and bringing some light.
I didn't forget to post the video of the tentacle scene from the other post btw, I'm just away from my office for a week. I'll do It when I' back. (just feeling guilty)

#### Sensei

##### TrueArt Support
of course, dividing by 2 or multiplying by 0.5 isn't going to split the vector by two.

middle_point = ( source_1 + source_2 ) / 2.0
or
middle_point = ( source_1 + source_2 ) * 0.5
or
middle_point = source_1 * 0.5 + source_2 * 0.5

f.e. source_1 = 10, source_2 = 100
10+100=110
110/2 = 55

#### marchermitte

##### Member
yes, that's what I thought at first and tried with the vectors (both with scalar multiply and vector multiply, distance from / to and add vectors)... but It only moved the middle cube toward the one that was currently moving. Scale on the other hand works just as expected.

#### Sensei

##### TrueArt Support
yes, that's what I thought at first and tried with the vectors (both with scalar multiply and vector multiply, distance from / to and add vectors)... but It only moved the middle cube toward the one that was currently moving. Scale on the other hand works just as expected.

It works for me either way.

yes, that's what I thought at first and tried with the vectors (both with scalar multiply and vector multiply, distance from / to and add vectors)...

Scalar multiply nor distance node should not be touched in this project!

You could use distance from first item to second item,
distance from first item to third item,
then divide 1st by 2nd,
and receive relative distance between them in 0...100% (1.0) range, use it as f.e. parameter to Gradient changing color of object how close it's to one item than to other item.

Last edited:

#### marchermitte

##### Member
You could use distance from first item to second item,
distance from first item to third item,
then divide 1st by 2nd,
and receive relative distance between them in 0...100% (1.0) range, use it as f.e. Parameter to gradient changing color of object how close it's to one item than to other item.

smart!

#### erikals

thanks, haven't had the use for it, always wondered how it was done though.

[saved]