Kenn Nilsson Posted February 17, 2013 Posted February 17, 2013 So I've taken a rather long break from scripting in SL and have come back with an interest in creating some pathfinding scripts. My first attempt, I thought, was rather simple.1 - I created a prim 4m wide, 4m tall, 8m long2 - I decided to make it navigate from point A to point B using the following script:integer ipos = 0; vector vpos; list stations = ["<28.0, 228.0, 53.0>", "<28.0, 28.0, 53.0>", "<228.0, 28.0, 53.0>", "<228.0, 228.0, 53.0>"]; default { state_entry() { llCreateCharacter([CHARACTER_DESIRED_SPEED, 30.0, CHARACTER_MAX_SPEED, 40.0, CHARACTER_RADIUS, 5.0]); } touch_start(integer total_number) { if(ipos > 3) ipos = 0; vpos = (vector)llList2String(stations, ipos); llOwnerSay((string)vpos); llNavigateTo(vpos, [FORCE_DIRECT_PATH, FALSE]); ipos += 1; } } 3 - I touched the object. Nothing happened.As far as I understand, the above script SHOULD have worked ... the z position of 53.0m is 0.5 meters above ground level.
Qie Niangao Posted February 17, 2013 Posted February 17, 2013 It's very difficult to recreate the test conditions in order to know what's going wrong, but a couple of suggestions. First, it's a good idea to slip in llDeleteCharacter() before llCreateCharacter() so you know you're starting with a clean slate. Second, what follows is a bit of code that helps identify why pathfinding isn't doing what you expect. (I stole it from a jira entry from way back, but I'd guess it gets used a lot.) list PFE_REPORTS = [ PU_SLOWDOWN_DISTANCE_REACHED, "Near the Goal (SLOWDOWN_DISTANCE_REACHED)", PU_GOAL_REACHED, "Goal Reached (GOAL_REACHED)", PU_FAILURE_INVALID_START, "Fail: Can't Start (INVALID_START)", PU_FAILURE_INVALID_GOAL, "Fail: Wrong Goal (INVALID_GOAL)", PU_FAILURE_UNREACHABLE, "Fail: Lost Goal (UNREACHABLE)", PU_FAILURE_TARGET_GONE, "Fail: Goal is Gone (TARGET_GONE)", PU_FAILURE_NO_VALID_DESTINATION, "Fail: Path is Gone (NO_VALID_DESTINATION)", PU_EVADE_HIDDEN, "Evade: Now Hiding (HIDDEN)", PU_EVADE_SPOTTED, "Evade: Now Running (SPOTTED)", PU_FAILURE_NO_NAVMESH, "Fail: Missing Navmesh (NO_NAVMESH)", PU_FAILURE_DYNAMIC_PATHFINDING_DISABLED, "Fail: Can't Navigate Here (DYNAMIC_PATHFINDING_DISABLED)", PU_FAILURE_PARCEL_UNREACHABLE, "Fail: Can't Navigate to Goal (PARCEL_UNREACHABLE)" ]; reportPFEvent(integer value) { value = llListFindList(PFE_REPORTS, [value]); if (value < 0) { llSay(0, "Unknown Event ("+(string)value+")"); } else { llSay(0, llList2String(PFE_REPORTS, value+1)); }} and then an event handler in the script body: path_update(integer update, list reserved) { reportPFEvent(update); } My hunch is that it will fuss with "Fail: Lost Goal (UNREACHABLE)" because there's something amiss with the geometry of the character and the navigable mesh in the environment, but that's just a guess. [ETA: I meant to mention... although I expect you have much more elaborate plans for your pathfinding character, it occurs to me that if you've been away from LSL for a while, you might be interested in llSetKeyframedMotion(); if the objective is to move stuff around a predefined course, it will save tons of sim time (and some land impact) compared to a pathfinding equivalent.] 1
Kenn Nilsson Posted February 17, 2013 Author Posted February 17, 2013 Thank you Qie, your help is greatly appreciated ... both the profiling script and the llSetKeyframedMotion() suggestion. You're right, I do have a more complex idea for the pathfinding, but I do also have needs for a pre-defined course and would like to get away from the llSetTarget() + llMoveTo()/llApplyImpulse() setup. It turns out that the error given is "INVALID START" ... so now I just have to figure out what that exactly means.
Recommended Posts
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