Jump to content

llMoveToTarget (randome ocation)


2toe Bigboots
 Share

You are about to reply to a thread that has been inactive for 4120 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 4120 days.

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...