Jump to content

Fish wander script?


LuckyCreations1488303085
 Share

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

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

Recommended Posts

I have a great collection of animal scripts that ive created. Find me in-world for specifics or check out the bulk package here on the marketplace:  https://marketplace.secondlife.com/p/First-Class-Developer-Pack-Advanced-Creature-Code/1917547

 

For a free version, try:

 

 

integer random=5;//swim timer//global vectors  -  wanders within these pointslist points = [<84,61,50>,<83,62,50>,<82,63,50>,<81,64,50>];swim(){ vector swimpoint=llList2Vector(points,(integer)llFrand(llGetListLength(points))); llLookAt(swimpoint,0.6,4.7); llSleep(1.2); llMoveToTarget(swimpoint,8.0); llSetTimerEvent(llFrand(random));}default{state_entry(){llSetStatus(STATUS_PHYSICS,TRUE);swim();}timer(){swim();}}

 



 

 

Link to comment
Share on other sites

 


Dev Khaos wrote:

I have a great collection of animal scripts that ive created. Find me in-world for specifics or check out the bulk package here on the marketplace: 

 

For a free version, try:

 

 
integer random=5;//swim timer//global vectors  -  wanders within these pointslist points = [<84,61,50>,<83,62,50>,<82,63,50>,<81,64,50>];swim(){ vector swimpoint=llList2Vector(points,(integer)llFrand(llGetListLength(points))); llLookAt(swimpoint,0.6,4.7); llSleep(1.2); llMoveToTarget(swimpoint,8.0); llSetTimerEvent(llFrand(random));}default{state_entry(){llSetStatus(STATUS_PHYSICS,TRUE);swim();}timer(){swim();}}

 



 

 

 

Would setting a range for random coordinates also work for the waypoints? Using the coordinates you have listed, x= a random number between 80 and 85, y= a random numer between 60 and 65, z= a random number between 5 and 19 (that's to keep teh fish underwater :) )

Then, as the fish reaches a generated waypoint, a new set of coordinates are generated. I'm not a scritper, but it should go something like;

get the rezzed position;

start loop

x = random number

y = random number

z = random number

waypoint = (x,y,z)

travel to waypoint

go back to start loop

 

Link to comment
Share on other sites



That would look something like this:

*additionally, you could add a little something to randomize positive AND negative distances 

 

integer random=5;//swim timerinteger totalpoints =5;//number of random save points
integer distance = 5;
list points =[];swim(){ vector swimpoint=llList2Vector(points,(integer)llFrand(llGetListLength(points))); llLookAt(swimpoint,0.6,4.7); llSleep(1.2); llMoveToTarget(swimpoint,8.0); llSetTimerEvent(llFrand(random));}

getpoints(){integer i;
for(i=0;i<totalpoints;i++){
vector pos=llGetPos();
points+=<pos.x+llFrand(distance),pos.y+llFrand(distance),pos.z+llFrand(distance)>;
}
}default{on_rez(integer p){llResetScript();}
state_entry(){getpoints();llSetStatus(STATUS_PHYSICS,TRUE);swim();}timer(){swim();}}
Link to comment
Share on other sites

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