Falling in void after teleporting

local entityWillTeleport = PlayerPedId()

local _, groundCoordZ = GetGroundZFor_3dCoord(blipCoords.x, blipCoords.y, 99999.0)

RequestCollisionAtCoord(blipCoords.x, blipCoords.y, groundCoordZ)

while not HasCollisionLoadedAroundEntity(entityWillTeleport) do Wait(25) end

SetEntityCoordsNoOffset(
    entityWillTeleport, 
    blipCoords.x, 
    blipCoords.y, 
    groundCoordZ, 
    false, 
    false, 
    false, 
    true
)

When I teleport to a waypoint my character falls into, RequestCollisionAtCoord is not working properly.

How can I avoid this problem?

You can’t get ground coordinates from a place which isn’t loaded yet, as you’d see if you’d not discard the return value as _ but check for it.

You can try using this for

before teleporting and while not has collisionloaded
you can also freeze the entity while not collision is loaded

SetFocusPosAndVel(blipCoords.x, blipCoords.y, blipCoords.z, 0.00, 0.00, 0.00)

this do the trick for me

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.