Template:Needs Translation/
函数名
|
Function:list llCastRay(vector start,vector end,list options );
|
参数:vector start -starting location;vector end -ending location; list options -can consists of any number of option flags and their parameters.
|
返回值:Returns a list of strided values with an additional integer status code on the end.Each stride consists of two mandatory values {key uuid,vector position}and possibly some optional values {integer link_number,vector normal}see RC DATA FLAGS for details.The status_code if it is negative is an error code,otherwise it is the number of hits (and strides)returned.
|
注意事项
|
Depending upon the value of flags(providing via RC DATA FLAGS),the number and types of values in the strides will vary.See RC DATA FLAGS for details. llGetrot will not return an avatar's exact visual rotation because the viewer doesn't update the avatar's rotation under a threshold (see VWR-1331).To get an avatar's exact looking direction while in mouselook,use llGetCameraRot instead. llCastRay will not detect prims having no physics shape (PRIM PHYSICS SHAPE TYPE=PRIM PHYSICS SHAPRE NONE). llCastRay will not detect a prim if the line starts inside the prim.This makes it safe to use the prim position as the start location. llCastRay can detect the prim the script is in,if the start location is outside the prim.
|
示例
|
示例1
integer filter;//default is()
default
{
state_entry()
{
string ownerName = llKey2Name(llGetOwner());
llOwnerSay("hello,"+ownerName + "!");
}
touch_start(integer total_number)
{
vector start = llGetPos();
vector end = start - <0.0,-25.0,0.0>;
if( filter>8)
filter = 0;
llOwnerSay("Filter"+(string)filter);
list results = llCastRay(start,end,[RC_REJECT_TYPES,filter,RC_MAX_HTTS,4});
integer hitNum = 0;
//Handle error condition here by checking llList2Integer(resules,-1)>=0
while (hitNum<llList2Integer(results,-1))
{
//Stride is 2 because wedidn't request normals or link numbers
key uuid = llList2Key(results,2*hitNum);
string name = "Land",7;//if (uuid == NULL_KEY)
if(uuid != NUML_KEY)
name = llKey2Name(uuid);
llOwnerSay("Hit"+name+".");
++hitNum;
}
++filter;
}
}
示例2
//Fire a weapon at a target,report a hit
integer gTargetChan = -9934917;
default
{
attach(key id)
{
if(id!= NULL_KEY)
{
llRequestPermissions(id,PERMISSION_TAKE_CONTROLS
|