PDA

View Full Version : XPresso: Stay within range?


metagrey
09-07-2006, 12:24 PM
HI,
how is it possible with XPresso to have an object stay within a defined distance of another master object?
So the object is freely movable but when the master moves beyond the defined distance the slave must move with it.

thanks,

Srek
09-07-2006, 01:10 PM
Calculate the difference vector (by simply subtracting one global psotion from the other) and check for the length of this vector. If it is above the limit distance multiply the normal of the difference vector by the limit distance and add it to the slave objects global position.

Cheers
Björn

metagrey
09-07-2006, 01:17 PM
Calculate the difference vector (by simply subtracting one global psotion from the other) and check for the length of this vector. If it is above the limit distance multiply the normal of the difference vector by the limit distance and add it to the slave objects global position.

Cheers
Björn

great!
seems simple enough,
thanks

metagrey
09-07-2006, 02:01 PM
ok so how does one "check for the length" of a vector?

Srek
09-07-2006, 02:21 PM
Either use the distance node or a math node set to subtract and vector. If you use the math node you can simply use the resulting vector as a scalar (real value), xpresso will autoconvert any vector into the length of the vector if you connect a vector to a real port.
Cheers
Björn

metagrey
09-07-2006, 02:35 PM
Either use the distance node or a math node set to subtract and vector. If you use the math node you can simply use the resulting vector as a scalar (real value), xpresso will autoconvert any vector into the length of the vector if you connect a vector to a real port.
Cheers
Björn

ok thanks. and i suppose i'll have to make a user data field to input the required max distance away from the master object at which to make the slave a child of the parent. (using the virtual Parent preset from the content browser).

metagrey
09-07-2006, 10:50 PM
right so i've sorta got it working:

the distance between the "Master" Cube and the "Pet" Sphere is found then this is compared with a distance set by a User Data slider on the "Master" Cube. If the output is greater than the setting on the User Data slider,then the Virtual Parent XPresso is enabled.

However when i drag the "pet" sphere too quickly it goes beyond the invisible bounds set by the "masters" user data and gets stuck.

Anyone know how I can prevent this?

I've attached the file.

thanks,

Cactus Dan
09-07-2006, 11:58 PM
Howdy,

I'm not sure, but is this what you were trying to achieve?

Adios,
Cactus Dan

metagrey
09-08-2006, 12:56 AM
thanks CD!
thats exactly what i needed! Its a thing of beauty! Calling it a FIX is a HUGE understatement. I'm kinda disappointed that i was so way off.

I see that "virtual parent" wasn't even necessary.

Now i need to dissect this and figure out how to give one "master" multiple "pets".

thanks again,

Cactus Dan
09-08-2006, 01:16 AM
Howdy,

You're welcome. ;)

Adios,
Cactus Dan

Cactus Dan
09-08-2006, 01:20 AM
Howdy,

You can also string them together like this.

Adios,
Cactus Dan

metagrey
09-08-2006, 01:43 AM
hey that's pretty cool!

I was trying to give you another "useful" credit in the thread, but was told that i couldn't. :(

My main reason for neding this XPresso was because i am animating a character that needs to do high flying somersaults and cartwheels.

(the characters are in my portfolio)

I didnt want the IK targets to get too far out of reach when i move the character.
So I was thinking I'd use this XPresso to keep the foot and hand targets from falling too far behind.

the reason i used virtual parent before was so that if i rotate the "master" the "pets" would rotate too as if they were children of the "master".

However I'll be using a different null for those rotations anyway

thanks

metagrey
09-08-2006, 12:40 PM
I've changed a couple of things:

I moved the User Data slider to the "pets" so they can be easily copied without have to adjust the XPresso.
They can also have individual "Leash Lengths" set by their own sliders.

cheers

RenatoT
10-17-2006, 11:29 PM
This is "not at range" but maybe useful :)

Cheers
Renato

metagrey
10-18-2006, 03:08 AM
This is "not at range" but maybe useful :)

Cheers
Renato

that's pretty cool!
So anything can be dropped into the null object and it will begin to follow along in turn. :)
and the "Multiplier" slider regulates how close they stay to the "Master"
I'll have to look at it more closely to see how u did it.

thanks Renato

RenatoT
10-18-2006, 04:01 AM
Another change :)

Added min distance.

what kind of movement do you need ?


Cheers
Renato T.

metagrey
10-18-2006, 04:21 AM
Well this is what i was otiginally looking for:

to have a child object stay within a defined distance of another master object despite being in different heirarchies.
So the child object is freely movable but when the master moves beyond the defined distance the child object must move with it and rotate if it rotates. If there are many children, i needed them to be seperate fron each other not necessarily in a line.

Cactus Dan helped me out with a file which is higher up in the thread, and i made some alterations to suit what i needed.

It's attached to post #13 called "invisibleLeash"
thanks,

CGTalk Moderation
10-18-2006, 04:21 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.