Creating new object in game

Can anybody advice me?? Im new:blush:
I have in plan to create RTS game, when afer clicking a button , game will create many varariants of object_1, with custom names like: (“object1”+“Variablenumber”) for example caste001, castle002, castle003.

When I click left mouse, the building is created, but at second time, instead of creating another copy it moves. I was thinking to use option among object… but it did not helped.

Among objects groupName, create object named ... selects an object with the name from a group. I suspect pole002 isn’t a group, but an object.

Create a group in the editor (one of the icons in the top right of the editor) and add the objects you want to create to that group. Then use that group name instead of pole002.

Thank you for fast answer, hovewer this solution doesnt work

  • I created a group that contains only one object
  • Among group called group_bulding it creates object called “pole”+GlobalVariableString(nrpola)

where variable nrpola is ID=0 (lather want to increse variable every time to change name of object) so now we have pole0 object created (global variable nrpola=0 declared already)

Nothing shows up in game, but In case of using standard create object it works well, but after second time teleport obj1 instead creating next one.

You can’t use string version of the object name in put object around, and the Show action. They need the objects.

If you double click on either of those two actions, the parameter you’ve entered as a name will be underlined in red.

If you want to move the newly created object while the mouse is still down, I’d suggest adding an object variable to the object to flag that it’s under mouse control, and clearing it once the mouse button is released.

Hello, I just found a way how to make that code works,
It’s enough to just change ID+1 before build

It allows me to build a lot of buildings without “teleporting them.” because each ID is unique

BUT… after building new house ALL ID goes up +1. I want every ID to be unchanged.

The problem would be solved by a command like “change the variable of last created object” is there such a thing? Or something that will work around?

The simplest and easiest way is to keep the latest ID in a scene variable. When you create a new object, set the object id to the value of the scene variable ID, and then increment scene variable ID.

WRT the screen shot, if you don’t add conditions that narrow down the objects, GDevelop will apply the action to all objects. If you add conditions, it reduces or filters the list of objects to those that meet the conditions. However, keep in mind that this reduced/filtered object list only exists for that event and it’s sub/child events. Any sibling events (ones on the same level as the original event) will not use the same reduced/filtered object list.

Hope this makes some sense.