SimplyMaya Forums

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

Home / forum / Animation / Mel Scripts & Programming / avoidance behaviour
Register FAQ Members List Calendar Mark Forums Read

New Thread
 
Thread Tools
Old 10-11-2008, 04:52 AM   #1
bendingiscool
Subscriber
 
bendingiscool's Avatar
 
Join Date: Jul 2006
Location: London
Posts: 567
Thanks: 0
Thanked 1 Time in 1 Post
Default avoidance behaviour

Hi, I have a Rigid Body cylinder pottering around a scene driven by some simple expressions on the impulse. What I would like to do is avoid / go round other objects in the scene rather than just collide with them.

I'm guessing I would have to collect the worldspace of the object its coming close to or something like that?

Any ideas on this one would be very useful.

Cheers,

Chris
bendingiscool is offline   Reply With Quote
Old 11-11-2008, 01:37 AM   #2
bendingiscool
Subscriber
 
bendingiscool's Avatar
 
Join Date: Jul 2006
Location: London
Posts: 567
Thanks: 0
Thanked 1 Time in 1 Post
Default

Ok so far the I have 2 objects, one a passive RB, one a active RB that has an expression on its impulse to make it move in the Z direction.

Below is an expression that makes there colour change when getting with in a certain proximity of each other...

//get objects translates
vector $obj1=`getAttr obj1.translate`;
vector $obj2=`getAttr obj2.translate`;

//subtract one from other
float $mag = mag($obj2-$obj1);

//change colour when within certain proximity
if ($mag <= 10)
setAttr lambert1.color 1 .5 .5;
else
setAttr lambert1.color .5 .5 1;

This is showing it recognises the proximity, now how would I go about making the active RB go round the passive RB?

Thanks

Chris
bendingiscool is offline   Reply With Quote
Old 11-11-2008, 03:28 AM   #3
gster123
Moderator
 
gster123's Avatar
 
Join Date: May 2005
Location: Manchester Uk
Posts: 6,300
Thanks: 1
Thanked 51 Times in 45 Posts
Default

Could you not assign a radial fields magnitide to the closeness factor, so that when the object goes close to the other object a field (thats parented to the other object) then increases its magnitide based off the distance to "push" it away
__________________
"No pressure, no diamonds" Thomas Carlyle
gster123 is offline   Reply With Quote
Old 11-11-2008, 04:27 AM   #4
bendingiscool
Subscriber
 
bendingiscool's Avatar
 
Join Date: Jul 2006
Location: London
Posts: 567
Thanks: 0
Thanked 1 Time in 1 Post
Default

I like the idea, am currently workin on a way to do it without fields but will certainly give that a go.

Cheers as always,

Chris
bendingiscool 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.