Hi,
I have added list of sprites in a scene with name as follows:
bug1
bug2
bug3
bug4
bug5
I want to show random sprite in the scene by providing its name prefix “bug” and concatenate it with a random number ranging from 1 to 5. Example if random number is 3, bug3 is to be shown. Currently, GDevelop only allows to pick a fix object to be shown. Is there any object extension where I can specify its name to show that object on the scene?
Thanks
Are you talking showing or creating? You can create an object by name from a group.
1 Like
Hi,
I’m referring to showing, not creating.
You can pick objects in many ways. Unfortunately, you can’t use it’s name unless you use compare 2 strings. The issue with that is that compare 2 strings doesn’t pick the object like most conditions it only returns true and false. You could use it inside a for each object.
I created 5 bugs and put them into a group called Bugs.
Another way would be to use an object variable.
This uses an object variable named ID. You can assign the variable manually or use an action.
If you just want a random object then you could use the pick random object condition. The advantage of this is that you can pick the hidden objects first and then pick a random one and it would always choose a hidden object. With the other methods you would need to use an array or other method otherwise it would most likely choose objects that were already visible.
Hi,
Please advise how to add the action that I highlighted below.
I search for the keyword “variable” in gdevelop and nothing close to that is appearing