06-21-2007 11:36
Here's a list of some logic gates I've developed that will tell a AI where it is relative to a specified point. These are not complete scripts, but rather the "if-then" calculations that return values if a point is in front, behind, left, right, above, or below the bot's current location.


Using these logic gates I have made a vehicle which moves between 14 waypoints without colliding that has had an up-time of 8 days and counting without problems requiring the vehicle needing to be reset (can be found at the sim "This Land";). I am using strings as the returned values for ease of readability, but it is probably more efficient to use integers in your actual code.


In front/behind logic gate.
CODE


string direction;
vector mydir=llRot2Fwd(llGetRot());
vector tardir=llVecNorm(target-mypos);
if(llVecMag(mydir + tardir) <1)
{
direction= "behind";
}
else
{
direction = "in front";
}


left/right logic gate
CODE

string direction;
vector mydir=llRot2Fwd(llGetRot());
vector tardir=llVecNorm(target-mypos);
rotation test=llRotBetween(mydir,tardir);

if(test.z>0)
{
direction="right";

}
else if(test.z<0)
{
direction="left";

}



above/below logic gate
CODE

string direction;
vector tardir=llVecNorm(target-mypos);

if(tardir.z <0)
{
direction="below";
}
else if(tardir.z>0)
{
direction="above";
}
_____________________
My SLExchange shop

Typos are forgiven; desecrating the english language with reckless abandon and necrophilic acts is not.


The function is working perfectly fine. It's just not working the way you wanted it to work.