You do have to comment because the reader won’t guess that the latest created instance is the cloned one. So avoiding only one action to end-up with unclear events is not a win in my opinion.
How do you make the Ducklings follow the PlayerDuck? It may need a way to know their exact order, not only the latest.
I guess, It could be done by keeping the same distance from the player each frame. This way we don’t need to know the order, but it might give strange results (and it doesn’t seems like an obvious solution).
It think I would use an extension to keep an history of the trail and place them at a given distance according to their index in the object stack and separate them in case the trail is looping, but without using the object stack extension I don’t see a good solution.
Not sure I follow on this one. The person creating the game can comment this however they please? It’s the ease of events that makes this a better solution. I’m not looking at this as a one-size fits all for games and all templates (to be clear, there isn’t a one-size fits all solution for this today anyway)
Sadly I don’t have an idea how they did this part in the original discussion as I don’t have access to the project being discussed in the Construct thread. For this example, it was specifically just speaking to the deletion of the last created instance.
Cleanest would probably be if we had Pick Nth and an expression to access the instance creation order. Have a behavior on the ducklings, have it Pick Nth of (Object.Nth-1), and then move it towards that instance.
If we had access to UIDs. I’d probably track the last created UID, upon creation of a new duckling add that UID to an instance variable, then a for each where the instance follows the position of the instance with the UID in the variable.
I understand about the complexities (or not) of Object stack, but the underlying overhead of the code seems like it would be less with Pick last/first created (and potentially pick Nth or at least surfacing the UID) because these quantities already exist in the engine?
Less items being stored beyond what already exists. I don’t think they always replace one another, but I do believe the Pick options are important to have available from a perspective of flexibility for the user and potential avenues of building out events.
You would still need to loop on Duckling to set their position, so only the “add” action could be avoided at the price of not being able to handle more than 1 duck.
I don’t see the benefits. Not on this example either at least. Do you have any other examples in mind?
An infinite runner game where there is a desire to spawn powerups on the newest platform created but only after the last pickup has been grabbed. Can’t spawn the powerup at the time of the platform creation in this use case, and pick last will enable this to work without having to track object IDs as a separate variable. (On collision with powerup + Pick Last Created Platform > Spawn Powerup at Platform.Y+5 or something similar)
A “speed challenge” game or “racing” game with randomly generated maps made up of different instances of a “map piece” that has different orientations and collisions depending on which animation frame is randomly selected upon spawning, outside of the first and final piece which count as “Start” and finish. Being able to pick last was the desired scenario as it made it much easier to determine if you’ve hit the finish line (or if going in reverse, pick first) than tracking multiple variables.
Overall, I think even just exposing the instance UIDs via expressions (Object.UID) and some conditions (Pick newest UID, pick oldest UID, pick UID) would help accommodate most of these scenarios, and likely other scenarios.
If I were to do this, I would check the number of powerups in the scene when creating a new platform and create a new one only if there is none. The powerup wouldn’t be created on the same platform as in your solution, but I guess it doesn’t matter much and I think the logic is easier to follow this way. Also, if the user wants to create it on a special platform (higher than usual) or at a specific location in a map piece, the “pick last” wouldn’t work.
The finish line will probably be at a specific location of the map piece. Wouldn’t it make more sense to use an object for it and leave it only when creating the last piece?
I am not getting notifications for this thread now despite being set to watching, so it’s definitely being weird.
I don’t know that this achieves the same desired outcome, and I would say it doesn’t seem simpler than adding a subevent that just says “pick last created (platform) > create X at Platform.X+abc or Y()”
Maybe, but then you have to account for more objects and potentially add additional conditions to account for that rather than an event that is an inverted “Pick last” for the start, and a pick last event for the finish.
For the 2 cases, both your solution and mine are about the same number of events. But, I think that the logic is easier to follow if it’s done at the creation rather than using a “last created” condition to find back the instance and do the logic then.
It’s also probably more efficient for the CPU because running the “last created” condition every frame is not free. For the finish line, it’s better to have an object marker with only one instances rather than picking the last of many because the generated code will build a list with all the instances of the object to give to conditions.
As the previous ones, these 2 cases don’t convince me that a “last created” condition would make users lives better.