Difference between revisions of "LlNavigateTo"

From Second Life Wiki
Jump to navigation Jump to search
m
m (<lsl> tag to <source>)
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Pathfinding alpha}}
{{LSL_Function
{{LSL_Function|
|inject-2={{LSL Function/position|pos|region=*}}
inject-2={{LSL Function/position|pos|region=*}}|
|func=llNavigateTo
func=llNavigateTo|
|func_desc=Directs an object to travel to a defined position in the region or adjacent regions.
func_desc=Directs an object to travel to a defined position in the region or adjacent regions.|
|func_footnote=Adjacent regions can be reached by extending the position vector into the nearby region.
func_footnote=Adjacent regions can be reached by extending the position vector into the nearby region.|
|p1_type=vector
p1_type=vector|
|p1_name=pos
p1_name=pos|
|p1_desc=&#32;for the character to navigate to.
p1_desc=&#32;for the character to navigate to.|
|p1_hover=&#32;for the character to navigate to.
p1_hover=&#32;for the character to navigate to.|
|p2_type=list
p2_type=list|
|p2_subtype=instructions
p2_name=options|
|p2_name=options
p2_desc=List of parameters to control the type of pathfinding used.|
|p2_desc=List of parameters to control the type of pathfinding used.
constants={{LSL_Constants/NavigateTo}}|
|constants={{LSL_Constants/NavigateTo}}
caveats=
|caveats=
* Must use llCreateCharacter first or the function will fail with a viewer error.
* Must use llCreateCharacter first or the function will fail with a viewer error.
* Vertical positions specified for any vectors should be chosen to be as close as possible to the actual height of the surface requested. Large difference between the provided vertical position and the actual terrain/object will result in failure of the behavior.
* Vertical positions specified for any vectors should be chosen to be as close as possible to the actual height of the surface requested. Large difference between the provided vertical position and the actual terrain/object will result in failure of the behavior.
* If you want to chase an agent or object as per the example below, it's much more elegant and less sim resource intensive to use [[llPursue]] instead.|
* If you want to chase an agent or object as per the example below, it's much more elegant and less sim resource intensive to use [[llPursue]] instead.
examples=
|examples=
<lsl>
<source lang="lsl2">
vector last_touched_pos;
vector last_touched_pos;
key last_touched_key;
key last_touched_key;
Line 47: Line 47:
     }
     }
}
}
</lsl> |
</source>  
notes=
|notes=
* FORCE_DIRECT_PATH can be used to rescue characters that have somehow fallen off the navigable zone as it doesn't use the navmesh.
* FORCE_DIRECT_PATH can be used to rescue characters that have somehow fallen off the navigable zone as it doesn't use the navmesh.
(Needs verification.)
(Needs verification.)
* The position vector can be set outside the current region by using extended range region coordinates: e.g., to go to the SE corner of the region to the East of the current one, you could llNavigateTo(<0.0, 512.0, 0.0>, []); |
* The position vector can be set outside the current region by using extended range region coordinates: e.g., to go to the SE corner of the region to the East of the current one, you could llNavigateTo(<0.0, 512.0, 0.0>, []);  
also_functions=
|also_functions=
* [[llCreateCharacter]]
* [[llCreateCharacter]]
* [[llDeleteCharacter]]
* [[llDeleteCharacter]]
Line 63: Line 63:
* [[llPursue]]
* [[llPursue]]
* [[llUpdateCharacter]]
* [[llUpdateCharacter]]
* [[llWanderWithin]]|
* [[llWanderWithin]]
also_events=
|also_events=
* [[path_update]]
* [[path_update]]
|history = Date of Release  [[ Release_Notes/Second_Life_Server/12#12.07.31.262785 | 31/07/2012 ]]
|cat1=Pathfinding
}}
}}

Latest revision as of 13:00, 22 January 2015

Summary

Function: llNavigateTo( vector pos, list options );

Directs an object to travel to a defined position in the region or adjacent regions.

• vector pos position in region coordinates for the character to navigate to.
• list options List of parameters to control the type of pathfinding used.

Adjacent regions can be reached by extending the position vector into the nearby region.

Option Value Parameters Default Description
FORCE_DIRECT_PATH 1 integer boolean ] FALSE ] Makes character navigate in a straight line toward pos. May be set to TRUE or FALSE.

Caveats

  • Must use llCreateCharacter first or the function will fail with a viewer error.
  • Vertical positions specified for any vectors should be chosen to be as close as possible to the actual height of the surface requested. Large difference between the provided vertical position and the actual terrain/object will result in failure of the behavior.
  • If you want to chase an agent or object as per the example below, it's much more elegant and less sim resource intensive to use llPursue instead.

Examples

vector last_touched_pos;
key last_touched_key;

default
{
    state_entry()
    {
        llCreateCharacter([CHARACTER_DESIRED_SPEED, 50.0]);
    }

    touch_start(integer total_number)
    {
        last_touched_key = llDetectedKey(0);
        last_touched_pos = llList2Vector(llGetObjectDetails(last_touched_key, [OBJECT_POS]), 0);
        llNavigateTo(last_touched_pos, []);
        llSetTimerEvent(0.2);
    }

    timer()
    {
        vector last_touched_pos_now = llList2Vector(llGetObjectDetails(last_touched_key, [OBJECT_POS]), 0);
        if ( llVecDist(last_touched_pos_now, last_touched_pos) > 1 )
        {
            last_touched_pos = last_touched_pos_now;
            llNavigateTo(last_touched_pos, []);
        }
    }
}

Notes

  • FORCE_DIRECT_PATH can be used to rescue characters that have somehow fallen off the navigable zone as it doesn't use the navmesh.

(Needs verification.)

  • The position vector can be set outside the current region by using extended range region coordinates: e.g., to go to the SE corner of the region to the East of the current one, you could llNavigateTo(<0.0, 512.0, 0.0>, []);

Deep Notes

History

Date of Release 31/07/2012

Signature

function void llNavigateTo( vector pos, list options );