[Solved] Phantom Ammo on screen

Hello everyone.

When my game is running, ammo drops down from above and explodes when it hits the ground. The code tells the item to be deleted and then show the explosion animation and play the sound. This is all working just as it should. But if I move the player left and right, it hits the place the ammo was and loses health, as though the ammo wasn’t deleted properly. I can’t see the ammo, but it shows up in the debugger count. The animation and the delete ammo instructions are in the same condition, so if the ammo is exploding it should also be deleted. I have the “For each item” condition set and it’s nothing to do with layers. Any ideas what’s happening?

From what you say, it looks like the animation event applies to all ammo while the deletion event doesn’t.
Sometimes, the logic of objects selection is a bit tricky with multiple instances. Luckily, some tools can help: there are some conditions to pick objects, and there’s the while loop. I would fiddle with those.

Hi Gruk, thanks for your reply.
I’ve tried messing with the “for each item” adding it in and taking it out but now it’s worse. I’m still getting the phantom ammo, but now I’m getting phantom collisions, with enemies getting killed when they haven’t been hit. Does it sound like something’s gone horribly wrong with the code and I might as well start again?


Who knows, feel free to give it a try :wink:
Or share your events so we can investigate, sometimes it’s just a missing capital, an extra quote… or a for each at the wrong place.

Ok, I solved the problem. It seems the “Destroy when outside screen” setting was the cause of it. I don’t know why, but I removed it and everything’s working fine. I also added an off-screen “roof” to the play area, to make sure any stray ammo didn’t get lost.


1 Like