Gdevelop, destroying one instance of an object (need help)

Hey, I’m new to gdevelop, i’ve arledy made 2 other posts in this forum and i got the help i needed from them, because of that the game i’m making is coming along nicely, i have however run into a problem that i’m struggling to deal with, i’m trying to create a flappy bird type game ( it has rpg elements and simple enemies ).

The movement in the game is simple, theres a force acting on the player to make him move forward and the player just repeatedly jumps, the platforms that i use like you would pipes in the real flappy bird, are spawned randomly ( within some parammters, their height and lenght is all the same some are just pushed higher up or further down than others ).

The problem is that, i can’t delete the plaftforms when they are out of the screen without breaking the game;

I tried using the " destroy when outside of screen " behaviour, when i do that platforms don’t spawn, i tought " it’s probably just because they spawn outside the screen further ahead of the player". So i tried the same thing but with an extra border thats always 1000 pixels behind the “player” sprite X position, but the same thing happens.

I also tried the “pick nearest object” condition with the " delete an object " action, i just created a random imobile sprite behind where the player starts the game so that it’s not visible to the player and with a timer, slowly destroy the plaftforms that where closer to it. Doesn’t work my guess is that the delete platform command just deletes every platform behind or ahead of the player at the same time.

If somoene knew if there is a way to destroy a single instance of an object ( or rather 2, top and bottom platform but i’m sure i can figure that part out ), or how to make the behaviour work in the way i need it to, or if anyone has any other ideas or better ways to make this work i would really appreciate the help.

( I also tried making the player sprite immobile and adding a force to the platforms, but it’s not working because for the player i only add a constant force once, for the platforms i have to add it every time one spawns, and adding the force to a recently spawned one adds it to all the others too, making their speed increase like crazy, so if anyone knows how to add a force to a single instance ( again acctually 2 instances top and bottom ) i think that would work too )

Thanks in advance dor any help :smiley:

Yeah, probably you are creating the platforms outside the screen, and they are automatically deleted, not sure why the extra border wouldn’t work.

Well, pick nearest do exactly that, pick nearest. If there are two platformers and both are too far away, it will pick the closest one, and then you delete it… In other words, if there are 10 platforms around (no matter the position) and you run the pick nearest >> delete event 10 times (0.17 seconds) you’ll delete them all :slight_smile:

You could just check if the platform X position is less than the player X position - left margin:

Conditions: X position of Platform is < Player.X() - 500 Actions: Delete object Platform

If you put the action to add a force just after creating the platform, this platform should be the only one being picked and moved:

Conditions: Conditions to create a Platform Actions: Create Platform Add a force to Platform, X = -300, Y = 0, damping = 1
Damping = 1 so you add the force only once but it keeps constant along the time :wink:

Yeah those are the things i’ve been trying to do no idea why it’s not working, guess i’ll just have to play around with it until i figure out what’s going on but thank you very much for the help!

Try to check the X position manually as I wrote there, if the platform X position is less than the player X position it means the platform is at the left of the player, if it’s less than player X position - 500 it means the platform is at 500 pixels at the left of the player and you can delete it.

I tried it and it causes a completely diffrent problem, it messes up the spawns, at first the platforms start spawning on top of eachother or really close together, after that they stop spawning all together :confused:
But it does delete the platforms behind the player properly, it’s so weird.

edit
WELL… i got it to work, i found a much easier and simpler way, i just created a random sprite that moves behind the player ( far enough so it’s not visible ), added a force to it, same as the player, and just made it so it deletes the platforms as they collide with eachother xD.

Thank you very much for all the help though, may not have worked but i did learn a bunch of usefull things in the process :smiley:

Deleting platforms should not affect the way the spawn… I think you have a problem there, but if it is working… that’s what matters :slight_smile: