llCreateCharacter
void llCreateCharacter(list Options)Convert link-set to AI/Physics character.
Creates a path-finding entity, known as a "character", from the object containing the script. Required to activate use of path-finding functions.
Options is a list of key/value pairs.
Parameters
-
Options(list)
create_character(){ // Clear any previous character behaviors llDeleteCharacter();
// MAX_SPEED is @ 20 by default llCreateCharacter([ CHARACTER_MAX_SPEED, 25, CHARACTER_DESIRED_SPEED, 15.0]);}
patrol_around(vector targetPos){ list points = [targetPos + <5, 0, 0>, targetPos - <5, 0, 0>]; llPatrolPoints(points, []);}
default{ on_rez(integer start_param) { llResetScript(); }
state_entry() { create_character(); }
touch_start(integer num_detected) { patrol_around(llGetPos()); }}Caveats and Important Notes
Section titled “Caveats and Important Notes”- You only need to use one
llCreateCharactercall per object; calling multiple times has no effect - One script can contain an
llCreateCharactercall and other scripts can exploit that with other path functions that require it llCreateCharacterstatus survives state changes, script resets, and rezzingllCreateCharacteris always required for all pathfinding functions- When an object becomes a character, its physics weight becomes fixed at 15
- If multiple scripts contain
llCreateCharacterin the same object, nothing untoward happens - If multiple scripts use conflicting path functions in the same object, one will take precedence randomly
CHARACTER_MAX_SPEED- In testing, a desired speed of 10m/s is plenty fast for most uses; higher speeds may produce unexpected results (particularly when navigating tight spaces or making sharp turns)CHARACTER_MAX_ANGULAR_ACCELminimum is 1.5708- The character’s shape is a capsule (cylinder with spherical ends) with a length and circular cross section controlled by
CHARACTER_LENGTHandCHARACTER_RADIUSparameters - The character’s true “length” cannot be smaller than twice the radius plus 0.1m
- The capsule is usually oriented vertically; use
[CHARACTER_ORIENTATION, HORIZONTAL]if you need your character to be horizontal- Use a vertical capsule whenever possible; horizontal capsules may become stuck more easily than vertical capsules
- Removing the script from a prim will not stop pathfinding behavior, similar to how particles and hover text remain. However, if the character encounters an error state, it will be unable to recover. Removing scripts from actively used characters is NOT recommended. To stop a pathfinding command use
llExecCharacterCmd(CHARACTER_CMD_STOP, []) - The root prim’s position determines the character’s height above the surface; if your character sinks under the surface or is too high above it, adjust the relative position of the root prim to the rest of the linkset
- The default value of
CHARACTER_STAY_WITHIN_PARCELdepends on theCHARACTER_TYPE:- If
CHARACTER_TYPEis set to anything other thanCHARACTER_TYPE_NONE, thenCHARACTER_STAY_WITHIN_PARCELwill default toTRUE, so always explicitly setCHARACTER_STAY_WITHIN_PARCELtoFALSEif you don’t want the character to stop at parcel borders
- If
Key Implementation Notes
Section titled “Key Implementation Notes”- If called on an existing character, all unspecified parameters other than character size will revert to their defaults (if not specified, character size will not change)
- Calling
llCreateCharacteragain is STRONGLY preferred over callingllDeleteCharacter()followed byllCreateCharacter()as it is much less taxing on the server