How to show a certain amount of hidden objects?

Imagine if you have 10 different objects on a screen. It’s names are Objects 1-10 and all of it are in the same object group. All these objects are hidden.

So how can I show an amount of objects that is equal to a certain variable? For example if the variable = 5, so it should make visible Objects 1-5 only .

You would use a repeat loop (Repeat Variable(variable) times) and use the action Create object from group to call the instances you want with a counter variable from 1 to 5.

I dont get it. The objects exist already on the scene. Why should i create anything from a group? I need if the Variable = 5 (for example) so the objects with names Object_1,Object_2,Object_3,Object_4,Object_5 become vsisble while Objects 6-10 are still hidden.

For example i can create a new string variable (Let’s call it “Pick”) that have a text “Object_” + the value of any other variable (5 in this case). This way i’m able to get a string variable with a text “Object_5”. How can i create any object with coordinates equal to X and Y of “Pick” variable . In my case it gonna be coordinates of Object_5. So if i change the value of the variable it should be Objects_6 coordinates or any other.

I tried to create 2 string Variables “PickX” and “PickY” equal to :
PickX = “Object_”+VariableString(MaxObject)+“.CenterX()”
PickY = “Object_”+VariableString(MaxObject)+“.CenterY()”

Now I have both Variables equal to a text “Object_5.CenterX” and “Object_5.CenterY”. It’s exactly what i need but there’s no any option to put it as a position of any object.

If it was possible i could put any other object to coordinates of the max object to check if it’s in a collision. After i could just create conditions like “If an object in collision with Object_5 show Object_5 and create the same object for Object_4” and so on. So how can i use the text “Object_5.CenterX” from a string variable as actual coordinates?

Is it possible to do it this way?

You need to add object variable to each object.

1 Like

Thank you. Your message gave me an answer. Never thought about this way of using object variables in a group.

I don’t think you can call objects like that, except to create them.
Using instance variables is a good way to go. :+1:

1 Like