Hello! I'm having an issue that you may be able to notice with this file
The relevant line of code is likely line 30 of bullet.lua. That's where the collision check and table.remove are. Other than that, I have no idea.
. When bullets are colliding with minions or enemies, sometimes but not every time there are extra bullets off to the side that are removed which shouldn't be.Bullets Disappearing when removing them during ipairs loop.
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Bullets Disappearing when removing them during ipairs loop.
Long story short, you can't modify the table you're iterating over. It won't work properly. Your can attempt traversing the table manually in controlled fashion. Or use alternative method that doesn't involves immediately removing items from the table.
Re: Bullets Disappearing when removing them during ipairs loop.
What you need to do is loop over the table backwards. This is because the length of the table changes over the course of iteration, so you can't use it as the ending point.
Code: Select all
for i = #tab, 1, -1 do
-- code
end
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
Who is online
Users browsing this forum: Semrush [Bot] and 3 guests