Page 2 of 2

Re: Bump error "item object must be added..."

Posted: Thu Dec 01, 2022 1:22 pm
by darkfrei
fridays18 wrote: Thu Dec 01, 2022 1:13 pm
darkfrei wrote: Thu Dec 01, 2022 12:57 pm Why you call update bullet by dead bullet?
what do you mean?
The error comes that you move the dead bullet, but the dead bullet must be removed from bullets list. Why the dead bullet is in this list?

Update:
The code must be like:

Code: Select all

function updateBullets (dt)
	for index = #Bulltes, 1, -1 do
		local bullet = Bullets[i]
		bullet:update (dt)
		if bullet.dead then
			table.remove (Bullets, index)
			world:remove (bullet)
		end
	end
end