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";
}