PointerEvent

An event that's generated when using the Pointer. (see Pointer.Down or Pointer.Up)

Functions

Impact CastRay ( Shape filterIn )
Impact CastRay ( nil filterIn, Object filterOut )
Impact CastRay ( CollisionGroups filterIn, Object filterOut )
Impact CastRay ( Shape filterIn, Object filterOut )

Casts a ray from PointerEvent screen coordinates and returns an Impact (can be nil).

The Impact contains information about the kind of thing that's been hit.

💡 Calls Ray.Cast under the hood. See Ray.Cast definition for more details about possible filters.

Pointer.Down = function( pointerEvent )
    local impact = pointerEvent:CastRay()
    if impact.Block ~= nil then
      print("block hit:", impact.Block)
    end

    -- this can also be done using a Ray object:
    local ray = Ray(pointerEvent.Position, pointerEvent.Direction)
    impact = ray:Cast()
    if impact.Block ~= nil then
      print("block hit:", impact.Block)
    end
end

Properties

Horizontal delta, not 0 when moving the pointer (see Pointer.Drag or Pointer.Drag2)

Vertical delta, not 0 when moving the pointer (see Pointer.Drag or Pointer.Drag2)

The direction of the ray cast from screen space PointerEvent.X and PointerEvent.Y into world space.

Indicates whether the PointerEvent represents a touch/click "down" event. If false, it represents a "up" event.

The index of the pointer that triggered the event.
1: first finger (touch screen)
2: second finger (touch screen)
3: third finger (touch screen)
4: left mouse button (mouse)
5: right mouse button (mouse)
6: mouse (no specific button, when mouse moves for example)

The world space origin of the ray cast from the screen. This is equivalent to Camera.Position.

Horizontal position of the pointer when the event happens, in screen coordinates. {0,0} represents the bottom left of the screen, and {1,1} the top right. X is close to 0.5 when pointing the horizontal center.

Vertical position of the pointer when the event happens, in screen coordinates. {0,0} represents the bottom left of the screen, and {1,1} the top right. Y is close to 0.5 when pointing the vertical center.