fivem icon indicating copy to clipboard operation
fivem copied to clipboard

Unable to Hide Head Component (drawable -1) after SetPedHeadBlendData has been called

Open Kuuzoo opened this issue 3 months ago • 4 comments

What happened?

After calling SetPedHeadBlendData() on a freemode ped, subsequent calls to SetPedComponentVariation(ped, 0, -1, 0, 0) fail to visually hide the head component, even with allowEmptyHeadDrawable true set. The native appears to execute successfully and GetPedDrawableVariation() returns -1, but the head remains visible. Head hiding works normally before any HeadBlendData is set.

Expected result

SetPedComponentVariation(PlayerPedId(), 0, -1, 0, 0) should hide the head component regardless of whether HeadBlendData has been previously set, as long as allowEmptyHeadDrawable true is enabled.

Reproduction steps

  1. Download and start the head_issue resource
  2. Execute in F8 console: allowEmptyHeadDrawable true
  3. Execute: /headtest2 → Head should disappear (working correctly - tests head hiding without blend data)
  4. Execute: /enablehead → Restores head visibility
  5. Execute: /headtest1 → Sets HeadBlendData then tries to hide head - head remains visible (BUG)
  6. Execute: /debugheadstatus → Confirms head component is set to -1 but head remains visually present

Importancy

Slight inconvenience

Area(s)

FiveM, Natives

Specific version(s)

FiveM Ver. 20139/beta, Server b18443/Win

Additional information

No response

Kuuzoo avatar Sep 25 '25 22:09 Kuuzoo

You can always try to hide the ped's head by setting the ped reset flag at index 166 (MakeHeadInvisible) to true.

e.g.:

SetPedResetFlag(
	PlayerPedId() --[[ Ped ]], 
	166 --[[ integer ]], 
	true --[[ boolean ]]
)

colistro123 avatar Sep 26 '25 15:09 colistro123

You can always try to hide the ped's head by setting the ped reset flag at index 166 (MakeHeadInvisible) to true.

e.g.:

SetPedResetFlag( PlayerPedId() --[[ Ped ]], 166 --[[ integer ]], true --[[ boolean ]] )

Thanks for the suggestion thought this sadly doesnt work the same as hiding only the actual head (drawable -1).

When setting flag 166 it will cut off everything ontop, so glasses, hats, etc. too. But because I wanna see only the glasses, heads, etc. without the head itself the flag 166 does not solve my problem.

Kuuzoo avatar Sep 26 '25 15:09 Kuuzoo

Problem

  • After applying SetPedHeadBlendData on a freemode ped, hiding the head with SetPedComponentVariation(ped, 0, -1, 0, 0) fails visually, even though GetPedDrawableVariation returns -1.
  • This happens because head blend bakes/caches the head mesh/texture. Without finalizing and forcing a variation refresh, the cached head remains visible.

What you need to do

  1. Apply head blend.
  2. Finalize the head blend (bake/refresh the mesh/texture).
  3. Clear all head overlays and remove hair/eyebrows that keep the head “looking present.”
  4. Set head component to -1.
  5. Force a ped variation update.

Critical requirements

  • Use a freemode ped: mp_m_freemode_01 or mp_f_freemode_01.
  • Ensure allowEmptyHeadDrawable true (set before starting and in the correct scope).
  • Run this while operating on the correct ped (your PlayerPedId).
  • Order matters. Do not skip FinalizeHeadBlend + UpdatePedVariation.

Working example (Lua)

-- Clears all head overlays (blemishes, beard, eyebrows, makeup, etc.)
local function clearAllHeadOverlays(ped)
  for i = 0, 12 do
    SetPedHeadOverlay(ped, i, 0, 0.0)
  end
end

-- Forces the game to reload ped variations and textures
local function updatePed(ped)
  -- noNetwork=true, reloadTextures=true, facial=true
  UpdatePedVariation(ped, true, true, true)
end

-- Hides the head reliably after applying a head blend
local function hideHeadAfterBlend(ped)
  if not DoesEntityExist(ped) then return end

  -- 1) Apply HeadBlend (replace with your own values)
  -- shapeFirst, shapeSecond, shapeThird, skinFirst, skinSecond, skinThird, shapeMix, skinMix, thirdMix, isParent
  SetPedHeadBlendData(ped, 21, 0, 0, 0, 0, 0, 0.8, 0.2, 0.0, false)

  -- 2) Update + finalize the head blend so the engine bakes the mesh/texture
  UpdatePedHeadBlendData(ped)   -- helps stability on some builds
  FinalizeHeadBlend(ped)
  Wait(0)                       -- give the engine a frame to apply

  -- 3) Remove overlays and hair so nothing visually “fakes” a head
  clearAllHeadOverlays(ped)
  SetPedComponentVariation(ped, 2, -1, 0, 0) -- remove hair

  -- 4) Actually hide the head (requires allowEmptyHeadDrawable true)
  SetPedComponentVariation(ped, 0, -1, 0, 0)

  -- 5) Force a variation refresh to clear caches/streaming state
  updatePed(ped)
end

-- Test commands
RegisterCommand('headtest2', function()
  local ped = PlayerPedId()
  -- Hide head without head blend (baseline check that works)
  SetPedComponentVariation(ped, 0, -1, 0, 0)
  SetPedComponentVariation(ped, 2, -1, 0, 0) -- remove hair
  clearAllHeadOverlays(ped)
  updatePed(ped)
end, false)

RegisterCommand('enablehead', function()
  local ped = PlayerPedId()
  -- Restore a basic head + hair
  SetPedComponentVariation(ped, 0, 0, 0, 0)
  SetPedComponentVariation(ped, 2, 0, 0, 0)
  updatePed(ped)
end, false)

RegisterCommand('headtest1', function()
  local ped = PlayerPedId()
  hideHeadAfterBlend(ped)
end, false)

RegisterCommand('debugheadstatus', function()
  local ped = PlayerPedId()
  print('Head drawable:', GetPedDrawableVariation(ped, 0))
  print('Hair drawable:', GetPedDrawableVariation(ped, 2))
end, false)

Common pitfalls

  • Not using a freemode ped. HeadBlend is only meaningful for mp_m_freemode_01/mp_f_freemode_01.
  • Missing allowEmptyHeadDrawable true. Set it before the resource runs.
  • Wrong order. The reliable sequence is: HeadBlend → UpdatePedHeadBlendData → FinalizeHeadBlend → clear overlays/hair → component 0 = -1 → UpdatePedVariation.
  • Hair/overlays still visible. Even if component 0 is -1, hair or overlays can visually imply a head; ensure they’re removed or set to opacity 0.
  • Timing. Waiting a frame (Wait(0)) after FinalizeHeadBlend helps the engine settle before you strip components.

weturnhell avatar Oct 03 '25 14:10 weturnhell

Problem

  • After applying SetPedHeadBlendData on a freemode ped, hiding the head with SetPedComponentVariation(ped, 0, -1, 0, 0) fails visually, even though GetPedDrawableVariation returns -1.
  • This happens because head blend bakes/caches the head mesh/texture. Without finalizing and forcing a variation refresh, the cached head remains visible.

What you need to do

  1. Apply head blend.
  2. Finalize the head blend (bake/refresh the mesh/texture).
  3. Clear all head overlays and remove hair/eyebrows that keep the head “looking present.”
  4. Set head component to -1.
  5. Force a ped variation update.

Critical requirements

  • Use a freemode ped: mp_m_freemode_01 or mp_f_freemode_01.
  • Ensure allowEmptyHeadDrawable true (set before starting and in the correct scope).
  • Run this while operating on the correct ped (your PlayerPedId).
  • Order matters. Do not skip FinalizeHeadBlend + UpdatePedVariation.

Working example (Lua)

-- Clears all head overlays (blemishes, beard, eyebrows, makeup, etc.) local function clearAllHeadOverlays(ped) for i = 0, 12 do SetPedHeadOverlay(ped, i, 0, 0.0) end end

-- Forces the game to reload ped variations and textures local function updatePed(ped) -- noNetwork=true, reloadTextures=true, facial=true UpdatePedVariation(ped, true, true, true) end

-- Hides the head reliably after applying a head blend local function hideHeadAfterBlend(ped) if not DoesEntityExist(ped) then return end

-- 1) Apply HeadBlend (replace with your own values) -- shapeFirst, shapeSecond, shapeThird, skinFirst, skinSecond, skinThird, shapeMix, skinMix, thirdMix, isParent SetPedHeadBlendData(ped, 21, 0, 0, 0, 0, 0, 0.8, 0.2, 0.0, false)

-- 2) Update + finalize the head blend so the engine bakes the mesh/texture UpdatePedHeadBlendData(ped) -- helps stability on some builds FinalizeHeadBlend(ped) Wait(0) -- give the engine a frame to apply

-- 3) Remove overlays and hair so nothing visually “fakes” a head clearAllHeadOverlays(ped) SetPedComponentVariation(ped, 2, -1, 0, 0) -- remove hair

-- 4) Actually hide the head (requires allowEmptyHeadDrawable true) SetPedComponentVariation(ped, 0, -1, 0, 0)

-- 5) Force a variation refresh to clear caches/streaming state updatePed(ped) end

-- Test commands RegisterCommand('headtest2', function() local ped = PlayerPedId() -- Hide head without head blend (baseline check that works) SetPedComponentVariation(ped, 0, -1, 0, 0) SetPedComponentVariation(ped, 2, -1, 0, 0) -- remove hair clearAllHeadOverlays(ped) updatePed(ped) end, false)

RegisterCommand('enablehead', function() local ped = PlayerPedId() -- Restore a basic head + hair SetPedComponentVariation(ped, 0, 0, 0, 0) SetPedComponentVariation(ped, 2, 0, 0, 0) updatePed(ped) end, false)

RegisterCommand('headtest1', function() local ped = PlayerPedId() hideHeadAfterBlend(ped) end, false)

RegisterCommand('debugheadstatus', function() local ped = PlayerPedId() print('Head drawable:', GetPedDrawableVariation(ped, 0)) print('Hair drawable:', GetPedDrawableVariation(ped, 2)) end, false) Common pitfalls

  • Not using a freemode ped. HeadBlend is only meaningful for mp_m_freemode_01/mp_f_freemode_01.
  • Missing allowEmptyHeadDrawable true. Set it before the resource runs.
  • Wrong order. The reliable sequence is: HeadBlend → UpdatePedHeadBlendData → FinalizeHeadBlend → clear overlays/hair → component 0 = -1 → UpdatePedVariation.
  • Hair/overlays still visible. Even if component 0 is -1, hair or overlays can visually imply a head; ensure they’re removed or set to opacity 0.
  • Timing. Waiting a frame (Wait(0)) after FinalizeHeadBlend helps the engine settle before you strip components.

Hi there, thank you for the detailed reply. In general I think I'm understanding what you are saying, but one thing that I don't understand at all is UpdatePedVariation. I don't find any documentation about this native for FiveM/GTA5... I can only find it for RedM/RDR3 🤔

Also using this native does result in an error on the fivem runtime. Did you actually test the little script you've shared and if so, didn't the native call error for you?

Would be cool if you could maybe dm me on discord (kuuzoo) so we could get it sorted faster 😅

Thanks in advance

Kuuzoo avatar Oct 15 '25 20:10 Kuuzoo