M MY Multiplayer: Wiki
Side
Kind

createColPolygon

Shared

Creates a collision shape shaped like a flat polygon, with no height limit until setColPolygonHeight gives it one.

element|false createColPolygon(float centerX, centerY, float x1, y1, x2, y2, x3, y3, ...)

Parameters

NameTypeDescription
centerX, centerYfloatA reference point, used only for a quick distance check before the polygon test. A vec2 also works.
x1, y1, x2, y2, x3, y3, ...floatThe vertices, in world coordinates and in order around the polygon: at least 3 and at most 256. Each may be two numbers or a vector.

Returns

The created colshape element, or false if it could not be created.

A collision shape detects players, peds, vehicles and objects by their position and fires onColShapeHit and onColShapeLeave (onClientColShapeHit and onClientColShapeLeave on a client). It goes away when the resource that created it stops.

Example

local lot = createColPolygon(1500, -1700, 1480, -1720, 1520, -1720, 1530, -1690, 1475, -1680)
setColPolygonHeight(lot, 10, 25)

See also