How to make object to avoid other objects?

All white area is baked navmesh. This objects are generated in runtime. The red square must rich the position of green one, but it trys to do it through the blue square. How to make it to walk by the path marked with orange arrow? (I use pathfinding system from Unity 3.5 beta)

alt text

do this:

//drag and drop this onto the red cube
var fwd = transform.TransformDirection (Vector3.forward);
function Update () {
if(Raycast(transform.position,fwd,10))
{
print("There is an object in front of the red cube");
transform.Translate(0,-1,0)//This can be:Translate(x,y,z)/Translate(x,z,y)
}

}
else{
print(“There is no object infront of the red cube”);
transform.Translate(0,+1,0)
}

Hi,

the samples unfortunatly are a bit funny with set ups and the null amount of code comments makes it even harder… anyway:

uncheck the “Is Kinematic” of the rigidbody component of your Agent and it will start taking in “consideration” obstacle using the normal physic engine routines. If you make your obstacles convex and “round-ish” it will avoid it ( thos I am currently isolating an issue where when it hits something, agent seems to los the will to carry on its path, but it’s not always…). If your obstacles are more complex and concave, you’ll need some custom scripting to detect this and readjust destinations to avoid obstacles.

Now, if you are actually looking for the navMeshPath to take in consideration dynamic obstacles, I am not sure I know the answer. It seems Agents are already taking in consideration other agents somehow, but not 100% sure. I have seen agents getting confused when another agent is coming right at him, maybe they indeed are working on such dynamic avoidance.

hope it helps,

Jean