entity | Entity pointer, gives start position of the ray |
dir | Direction of the ray |
ShapesType | Entities that can get hit by the ray: NX_STATIC_SHAPES = hit static shapes only. NX_DYNAMIC_SHAPES = hit dynamic shapes only. NX_ALL_SHAPES = hit both static & dynamic shapes. |
hitflag | Allows you to specify which field of Raycast Types you are interested in. NX_RAYCAST_ENTITY = the function returns the closest physics entity that was hit by the ray. (default ) NX_RAYCAST_IMPACT = the function returns the impact vector in world coords. NX_RAYCAST_NORMAL = the function returns the normal vector in world coords. NX_RAYCAST_FACE_INDEX = the function returns the faceID , internalFaceID and 0 in a vector. NX_RAYCAST_DISTANCE = the function returns the distance between the hit shape and the entity position. NX_RAYCAST_UV = the function returns the U and V coords. And 0 in a vector. NX_RAYCAST_FACE_NORMAL = the function returns the normal vector in world coords. NX_RAYCAST_MATERIAL = the function returns the material index of the shape. |
VECTOR* worldImpact = pXent_raycast ( pRL, vector(0,0,-1), NX_STATIC_SHAPES, NX_RAYCAST_IMPACT); if(worldImpact.z < -800) pXent_addforceglobal (my, vector(0,0,1000), pRL.x );
// display the "look at" entities VECTOR* lookat = vector(1,0,0); vec_rotate(lookat,my.pan); hit_ent = pXent_raycast(my, lookat, NX_ALL_SHAPES, NX_RAYCAST_ENTITY); str_cpy(temp_str,"nothing"); str_cpy(format,"I see "); if(hit_ent){ str_for_entfile (temp_str, hit_ent); str_cpy(format,"I see a "); } str_cat(format,temp_str); vec_set(temp,vector(my.x,my.y,my.z+30)); vec_to_screen ( temp, camera); pan_setdigits(char_panel, 1, temp.x, temp.y, format, my_font, 0, 0);