GDevelop icon indicating copy to clipboard operation
GDevelop copied to clipboard

Add "Pick no instances" condition (and action)

Open tristanbob opened this issue 2 years ago • 5 comments

Description

There are use-cases when a game developer wants to remove the currently picked instances.

In my case, I am checking when objects are no longer in collision with their spawner. When that happens, I create a new instance on the spawner and change the angle of the new object to match the spawner angle. (see screenshot)

Screenshot 2022-03-06 154239

I expected this change of angle to only affect my newly created object because the angle action is in the same event as the creation. However, it appears that my previous collision condition was picking all other instances that were not in collision with the spawner, so their angle was changed also.

I was able to hack around this by checking for a boolean variable that would never be never TRUE and then using the NOT condition to make the condition TRUE so that the actions are processed. (thanks @arthuro555 and @Silver-Streak for your advice and consulting on this issue)

Solution suggested

  • [ ] Add "Pick no instances" condition that operate the same as "Pick all instances"
  • [ ] Add "Pick no instances" action that operate the same as "Pick all instances"

tristanbob avatar Mar 06 '22 23:03 tristanbob

I wonder if this "Pick no instances" should actually be a fix of "Pick all instances". I guess that "Pick all instance" should act as a "Reset picking for object", because it has strange behaviors:

image

I would expect the "Pick all instances" to have no effect in both cases.

D8H avatar Mar 06 '22 23:03 D8H

I'm not entirely sure on that.

Pick All Instances as it exists today can be useful for when you're wanting to add other objects entirely to a picked instance list, or want to re-add more of the same objects to the picked list that were excluded earlier (due to conditions). It doesn't work the same as a "pick no instances of X" would, which would empty the current picked objects list entirely.

Silver-Streak avatar Mar 06 '22 23:03 Silver-Streak

Pick All Instances as it exists today can be useful for when you're wanting to add other objects entirely to a picked instance list, or want to re-add more of the same objects to the picked list that were excluded earlier (due to conditions). It doesn't work the same as a "pick no instances of X" would, which would empty the current picked objects list entirely.

When a condition pick no object it usually doesn't apply the actions. What would a action do if it's called with no instance in parameter?

D8H avatar Mar 06 '22 23:03 D8H

While I can see what you are mentioning, keep in mind that pick all/none doesn't have to exclusively be for one object type. By having a "Remove all X from selected object list" (pick no instances of X), it should allows users to have much more granular control over events that involve object groups.

Lets say you have an object group that is "DamagesPlayer", you have all of your enemies and projectiles in it, as well as stuff like wall spikes. Your player has a bomb that destroys all enemies and their projectiles that touch the explosion image, but shouldn't destroy spikes.

You could make and maintain two more object groups (and would have to today), meaning you are maintaining three object groups every time you add a new enemy or projectile type. With pick no instances of X, you could have a single object group used in the event, and use the action (and or condition) to drop all spikes from the picked object lost so they arent destroyed by the explosion if it collides with the image.

Edit: also, to answer your question specifically, since the event is already processing, any actions that would apply without the object still occurs, but any action that requires an object wouldn't occur. This already happens today if you have an action that targets an object below a delete action in the same event.

In most cases the pick no instances of X would be used when you are needing to clear the selected object list to specifically target a single instance later. Like when using the number of objects condition or count expression (which picks all instances) in an event where you want to spawn another if it is below a certain amount, you would use the count condition, clear the list with the action, then create and target only the new instance in the same event.

Silver-Streak avatar Mar 07 '22 05:03 Silver-Streak