event.x

Type Number
Event collision
Revision Release 2024.3703
Keywords collision, x
See also event.y

Overview

The x position where the collision event occurred. Note that the reported collision position can be influenced by physics.setAverageCollisionPositions() and physics.setReportCollisionsInContentCoordinates().

Gotchas

Example

local function onCollision( event )

    if ( event.phase == "began" ) then
        print( "began: " .. event.object1 .. " & " .. event.object2 )
        print( "position: " .. event.x .. "," .. event.y )
    elseif ( event.phase == "ended" ) then
        print( "ended: " .. event.object1 .. " & " .. event.object2 )
        print( "position: " .. event.x .. "," .. event.y )
    end
end