# createColPolygon (Shared)

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

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Shared
- **Category**: Collision shapes
- **URL**: https://wiki.mymp.gg/en/createColPolygon

## Syntax

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

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `centerX, centerY` | `float` | A reference point, used only for a quick distance check before the polygon test. A `vec2` also works. |
| `x1, y1, x2, y2, x3, y3, ...` | `float` | The 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

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

## See also

- [setColPolygonHeight (Shared)](https://wiki.mymp.gg/en/setColPolygonHeight.md): Limits between which heights a collision polygon detects elements.
- [getColPolygonHeight (Shared)](https://wiki.mymp.gg/en/getColPolygonHeight.md): Returns between which heights a collision polygon detects elements.
- [createColRectangle (Shared)](https://wiki.mymp.gg/en/createColRectangle.md): Creates a rectangular collision shape, aligned with the world's axes and with no height limit.
