View Full Version : avoidance behaviour
bendingiscool
11-12-2008, 10:03 AM
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
11-13-2008, 07:57 AM
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
laxman
11-13-2008, 02:15 PM
One thing you might want to try is a simplification done in video games. Basically, parent a cube to each object, scale it so that the object fits inside the cude and set its visibility to 0. Now instead of colliding with the object, you can collide with the cube. Start with something like this to just get something simple working first.
As for the collision detection, you will probably have to make the script keep track of the coordinates and size of each cube at every frame and predict the cube's position several frames ahead (this is more complicated that games because you want to avoid objects, in games they just collide).
I'm not really sure where to start with this, but hopefully this helps.