Sprite(Player and Bullets) doesnt have an Lua proxy sometimes

Edit// So it's been a while and I found a solution to my problem back in april but yeah...

So basically what worked for me was to add:

collectgarbage("generational",300)

to my main script.

There are probably better ways which are less demanding, but I just wasn't able to find a better soulution and it's still better for the framerate of my game than running the garbagecollector normally and my game isn't that demanding.

HI i made metroidvania with lua on Windows with VisualStudio code and the ldtk with theHelp of the Tutorial from SquidGodDev and encountered the Problem that Enmies and Bullets had a Chance to dont have an lua proxy while destroying each other what I thought I fixed by adding some line in the destroy function which stops the Update loop of the object before its removed.
I thought this worked well but now it happens that If you destroy an Enemie there is a chance that there is still some sort of collision detection which destroys bullets and crashes the game if a player or another enemie collides with it, additionally theres also the problem that the player also has a chance to don´t have a lua proxy when changing the level or dashing near a Wall which is near the other level I tried to fix this by stopping the whole game Update when switching rooms it doesnt help much.

I am not abel to Replicate these errors consitent and it feels very random, when and if some of them occure.

1 Like