Jump to content

Pathfinder questions


Loki Eliot
 Share

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

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

Recommended Posts

Has anyone spent enough time playing with the pathfinder scripts to know if this scenario is possible and if so how best to go about it. Want a pathfinder cube to be the colour orange when following or chasing or running away from a user. The colour green when not moving and red when reaching a specific distance from a user.
Link to comment
Share on other sites

I've spent about 10 minutes playing with pathfinding, and I don't really code, but your issue could be solved strictly by a distance sensor function. Just base it all on how far a person is from the cube. Considering that each of the pathfinding functions are triggered by script, you could also change the color when that script function is true, like chasing. With a distance sensor, you could actually make the color change gradually from, for example red to green, depending on the distance.

Hmmm, I should really start coding my own stuff. I just hate staring at code all day. Pathfinding is definitely a good reason to start.

Link to comment
Share on other sites

I haven't coded with it yet, but by looking at the wiki page of LSL functions for it, here are my suggestions:

For changing color when moving, generally, you have to code your own logic to determine when you want your object to start following/chasing/evading. When you do, you can add the commands to change color

For the other two, there is a new event path_update [http://wiki.secondlife.com/wiki/Path_update] which has a number of useful status constants that you can use for this very effect.

PU_SLOWDOWN_DISTANCE_REACHED could be use to tell if the object is near the goal (player) but I don't think you can specify the distance criteria.

PU_GOAL_REACHED, PU_FAILURE_UNREACHABLE, PU_FAILURE_TARGET_GONE could be used to tell if the object has stopped moving (though if it has the wander behavior, this may not occur.)

Link to comment
Share on other sites

This prettry much demonstrates what you're asking for...

integer goal = PU_GOAL_REACHED;
integer faces = ALL_SIDES;
integer handle;
integer pursuing = FALSE;

vector Orange = <1,.5,0>;
vector Green = <0,1,0>;
vector Red = <1,0,0>;
vector White = <1,1,1>;

default
{
on_rez (integer foo)
{
llResetScript();
}

state_entry()
{
llSetColor(White, faces);
handle = llListen (0,"",llGetOwner(),"");
llOwnerSay ("Ready...");
}

listen (integer channel, string name, key avKey, string message)
{
if (message == "stop")
{
pursuing = FALSE;
llOwnerSay ("stopping...");
llSetColor (Green,faces);
llDeleteCharacter();
return;
}

if (message == "pursue")
{
pursuing = TRUE;
llOwnerSay ("pursuing");
llSetColor(Orange, faces);
llDeleteCharacter();
llCreateCharacter([CHARACTER_DESIRED_SPEED, 20.0]);
llPursue(avKey, [PURSUIT_OFFSET, <0, 0.005, 0>, REQUIRE_LINE_OF_SIGHT, FALSE]);
return;
}

if (message == "evade")
{
pursuing = FALSE;
llOwnerSay ("evading");
llSetColor(Orange, faces);
llDeleteCharacter();
llCreateCharacter([CHARACTER_DESIRED_SPEED, 20.0]);
llEvade (avKey, []);
return;
}
}

path_update(integer type, list reserved)
{
if (pursuing)
{
if (type = goal)
{
// goal reached...
llOwnerSay ("goal reached...");
llSetColor (Red, faces);
llDeleteCharacter();
}
}
}


Link to comment
Share on other sites

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