GDevelop icon indicating copy to clipboard operation
GDevelop copied to clipboard

Add expression to get object group size

Open AlexandreSi opened this issue 2 years ago • 2 comments

Description

When creating a random object in a group, it would be easier to get the group size to create an object from its name with: "Object" + toString(RandomInRange(1, Group.objectCount()))

Solution suggested

Add a property to the group or an expression to get it.

Alternatives considered

None found

AlexandreSi avatar Mar 08 '23 10:03 AlexandreSi

I think something like this should not be exposed, because:

  • I doubt it's useful: when users create random objects they will likely do something specific on them so it's better to pick a number and create each object explicitly.
  • People will confuse it with SceneInstancesCount(Object)

D8H avatar Jul 03 '24 09:07 D8H

I think this could be useful for a lot of scenarios. I've had a situation in the past where I could have used it.

Maybe to avoid confusion you call it something like group.Members() or MemberCount().

Silver-Streak avatar Jul 05 '24 05:07 Silver-Streak