Enable collision for streaming object

Hello,

I’m currently streaming this bed but I can’t get collision to work, my player is able to just walk right through it.

Here’s my test code:

Citizen.CreateThread(function()
  local model = RequestModel('v_49_motelmp_bed')

  if not HasModelLoaded(model) then
    Citizen.Wait(1)
  end

  -- create the bed
  local entity = CreateObject(model, bed.x, bed.y, bed.z, false, false)
  
  -- test any collision methods and see which work
  SetEntityCollision(entity, true, true)
  SetEntityLoadCollisionFlag(entity, true)
  SetEntityProofs(entity, true, true, true, true, 1, true)
  SetEntityNoCollisionEntity(entity, false, true)

  -- debug info
  print(IsAnEntity(entity))                      -- returns 1
  print(IsEntityAnObject(entity))                -- returns 1
  print(DoesEntityExist(entity))                 -- returns 1
  print(DoesEntityHavePhysics(entity))           -- returns false
  print(HasCollisionLoadedAroundEntity(entity))  -- returns 1
  print(GetEntityCollisonDisabled(entity))       -- returns false

  FreezeEntityPosition(entity, true)
  SetModelAsNoLongerNeeded(entity)
end)

Is there anything I’m missing?

Update

It appears the collision for this model is apart of the motel room itself and not the model as a separate entity. So I don’t think collision will work for this entity.

1 Like