Jump to content

llMoveToTarget (randome ocation)


2toe Bigboots
 Share

You are about to reply to a thread that has been inactive for 4685 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

If the land is square or rectangular you can use a fairly simple formula to randomly choose any point within your land:

default {
    touch_start(integer num) {
        vector C = <50.0,50.0,50.0>; // parcel SW corner
        float  W = 200.0;
        float  H = 100.0;
        vector p = <llFrand(W) + C.x, llFrand(H) + C.y, C.z>;
        if (llVecDist(llGetPos(), p) > 65.0) {
            llSay(0, "Too far, shortening...");
            p = llVecNorm(p) * 65.0;
            p.z = C.z;
        }
        llSay(0, (string)p);
    }
}

Since the move distance limit is 65.0m, there is a check to see if the new position is too far. In that case, the vector is normalized, then stretched out to 65m

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4685 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...