GetHeadingFromVector2d
Docslocal retval = GetHeadingFromVector2d(dx, dy)Description
dx = x1 - x2
dy = y1 - y2Parameters
| Name | Type | Description |
|---|---|---|
dx | float | — |
dy | float | — |
Returns
floatReturns a floating-point number.
local retval = GetHeadingFromVector2d(dx, dy)dx = x1 - x2
dy = y1 - y2| Name | Type | Description |
|---|---|---|
dx | float | — |
dy | float | — |
floatReturns a floating-point number.
-- Smoothly rotate ped to face an entity
QBCore.Functions.LookAtEntity(
targetEntity, -- entity to face
3000, -- timeout ms (max 5000)
2.0 -- turn speed (max 5.0)
)Uses GetHeadingFromVector_2d to calculate target heading from direction vector, then smoothly interpolates current heading with variable turn speed. Handles heading wrap-around (±180°). Speed decreases as approaching target heading for smooth deceleration.
No snippets yet. Be the first to contribute!