Anyone know how to get the Objects in a Group using Java Script? GDevelop object groups that is

I don’t know if it’s changed since then but I don’t think you can.

The concat method works. I like that.

let obj = runtimeScene.getObjects("NewSpriteA").concat(runtimeScene.getObjects("NewSpriteB"))

EDIT: Groups do work with extensions because you’re passing off the picked objects and the code uses the extension parameter name not the Group name. The calling event uses the group name.

You need to setup a parameter in a function and then get the objects through that parameter.

This rotates a random object using the function parameter OBJ. It doesn’t matter if it’s an object or a group.

const obj = eventsFunctionContext.getObjects("OBJ");
obj[Math.trunc(Math.random()*obj.length)].setAngle(Math.random()*360)
1 Like