GetEntitySensorPoints

From OxeyeWiki

Jump to: navigation, search

physics:getEntitySensorPoints(entityId)

Fetches a list of current sensor intersection points for a given entity. This list will not include real collisions, they are stored in a separate list and are fetched with getEntityCollisions.

Parameter Expected Type Description
enitityId An integer The entity's body identifier.
Returns

Returns a table containing collision elements (see below). If no intersections are found, this method returns nil to save some garbage collection performance. In other words, the returned table is never empty, it's either nil or non-empty.

Daisymoon Physics Lib


Collision Info

The returned table contains a list of intersection points. Each point has the following info:

Parameter Type Description
x A number The world X position of the collision point, measured in meters.
y A number The world Y position of the collision point, measured in meters.
nx A number The collision point normal's normalized X value. This value has no meaning for intersections.
ny A number The collision point normal's normalized Y value. This value has no meaning for intersections.
impulse A number The collision impulse. This value has no meaning for intersections.
id An integer The entity identifier of the body that this entity has collided with.
userData A string If the other entity has userData in the shape that this entity has collided with, that userData will be copied to this value. This is usually nil. See Common Shape Settings.


Example


   local collisions = physics:getEntitySensorPoints(player.body)
   if collisions then
      for index, info in ipairs(collisions) do
          local userData = info.userData or "n/a"
          print("Intersection with ".. info.id .. " at (" .. info.x .. ", " .. info.y .. "), " .. userData)
      end
   end

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox