System RayWorldIntersection

From CryWiki

Jump to: navigation, search

System.RayWorldIntersection(vec3, vec3, number, number, number, number, table)

Description

This function checks, if a ray with a certain position and a certain direction intersects with something.

Arguments

  1. Start position
  2. Direction
  3. Maximum number of hits
  4. Entity types (ent_all, ent_terrain, ent_static, ent_rigid, ent_sleeping_rigid)
  5. Entity with this id will be skipped
  6. Entity with this id will be skipped (?)
  7. Table to store the hit data

Returns

The number of hits

Example

Lua (example)
local from = g_localActor:GetPos(); -- player position
    from.z = from.z + 1.6;  -- eye-height
    local dir = g_localActor:GetDirectionVector();
    dir = vecScale(dir, 50);  -- 50 units distance is max
    local skip = g_localActor.id; -- skip ourself
    local hitData = {};  
    local hits = Physics.RayWorldIntersection(from, dir, 1, ent_all, skip, nil, hitData);
 
    if (hits > 0) then
        CryAction.PersistantLine(from, hitData[1].pos, {1,0,1}, "myRay", 5);
    else
        Log("Raytrace failed.")
    end


Personal tools