Spawn object on the ground

Hi,
I can’t make my object spawn on the ground. What am I doing wrong ?

Citizen.CreateThread(function()
	while true do
        Wait(1)

        x, y, z = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
        
        RequestModel("prop_beach_fire")
        while not HasModelLoaded("prop_beach_fire") do
           Wait(1)
        end

        local object = CreateObject("prop_beach_fire", x, y, z, true, true, true)
        PlaceObjectOnGroundProperly(object) -- This function doesn't seem to work.
end)

The object spawns but in the air. Above my head :smiley:

3 Likes

Because the object spawn with player coordonate and it place above your head !

Yeah but shouldn’t this function work PlaceObjectOnGroundProperly(object) ?
Even when I spawn the object 10m away it stays in the air.

Maybe remove your PlaceObjectOnGroundProperly and spawn your object with x, y, z - something (to spawn your object closer on the ground, example : CreateObject(“prop_beach_fire”, x, y, z-1, true, true, true) )
It’s just a suggestion ^^’

did you succeed? And how?

Nope I didn’t. I’m trying to do it manually as Kyominii has suggested but I’m pretty sure there’s a proper way.

This one works :slight_smile:

Citizen.CreateThread(function()
	local nbObjetsCrees = 0
	while nbObjetsCrees < 1 do
        local coke1 = CreateObject("prop_drug_package", 994.436, -2907.12, 5.00214, true, true, true)
        PlaceObjectOnGroundProperly(coke1)
		nbObjetsCrees = nbObjetsCrees + 1
		
	end
end)
2 Likes

Yes, I realized it didn’t work because the prop I wanted to spawn was bugged : prop_beach_fire.
I tried with other props and it works…Strange.

Hi her hope for help :slight_smile:

I have try to place an object it works fine, but I wish to rotate it when I place it.

I have try with this parameters:
local window1 = CreateObject(“v_ilev_go_window”,-258.477, -978.453, 31.240, 58.6510239, true, true, true, true)

But it do not work, can anybody help me on what I can do ? :slight_smile: .

Maybe try this…

Citizen.CreateThread(function()
	local nbObjetsCrees = 0
	while nbObjetsCrees < 1 do
        local window1 = CreateObject("v_ilev_go_window", -258.477, -978.453, 31.240, 58.6510239, true, true, true)
        PlaceObjectOnGroundProperly(window1)
		nbObjetsCrees = nbObjetsCrees + 1
		
	end
end)

I can only assume that the issue has been resolved after 6 years…

1 Like