06-04-2006 07:27
I made a tiny sphere and have made it traverse the world map however I want to to detect when it hits the edge of the world and change direction. My problem is its not detecting the edge of the world. I think this is because it is traveling by say intervals of 10m for example and it is hitting on a north edge of world sim 255 then it asks if edgeofworld 265 its not getting a TRUE result that it should thereby triggering the direction change. can anyone help me with this?

here is the code... keep in mind this has no real use as of yet its just something neat i like to sit on and ride around the world.

CODE

integer iterations = 0;
vector pos;
vector temppos;
vector temppos2;
float leap = 10;
vector direction = <0,leap,0>;
float dirmod = randBetween(0.0,4.0);
integer haltnow = FALSE;
while ( iterations < 1000 ) {
pos = llGetPos();
//llSay(0,"CMON!!!");
if ( dirmod <= 1.0 && WouldGoOffWorld(pos,pos+<0,leap,0>) == FALSE ) { //north
//llShout(0,"GOING NORTH!!");
while( llVecDist(llGetPos(), pos+<0,leap,0>) > 0.01 ) {
llSetPos(pos+<0,leap,0>);
}
} else if ( dirmod > 1.0 && dirmod <= 2.0 && WouldGoOffWorld(pos,pos+<0,-leap,0>) == FALSE ) { //south
while( llVecDist(llGetPos(), pos+<0,-leap,0>) > 0.01 ) {
llSetPos(pos+<0,-leap,0>);
}
} else if ( dirmod > 2.0 && dirmod <= 3.0 && WouldGoOffWorld(pos,pos+<-leap,0,0>) == FALSE ) { //west
while( llVecDist(llGetPos(), pos+<-leap,0,0>) > 0.01 ) {
llSetPos(pos+<-leap,0,0>);
}
} else if ( dirmod > 3.0 && WouldGoOffWorld(pos,pos+<leap,0,0>) == FALSE ) { //east
while( llVecDist(llGetPos(), pos+<leap,0,0>) > 0.01 ) {
llSetPos(pos+<leap,0,0>);
}
} else {
llShout(0,"End Of World... CHANGING DIRECTION");
dirmod = randBetween(0.0,4.0);
}
iterations++;
}
llShout(0,"Powering Down... Out Of Gas!");





am i mucking the math up somewhere?