So I’m working on a tower defense/city builder where you place your workers and troopers and do a battle against an AI…
only problem is that when ever I place(create) an object it doesn’t act individual…[for example]
So I hire two workers and now get to select where to spawn them so then I place them in the field and now I want them to work so I click on one only to have both of them(Technically) selected.
Why you ask?Well there both the same object so when I click one I click all of them, and I could make 60 different workers so that they all have have a different ID’s…but… I think its to much trouble reason being I already did that, and it gets to messy with the selecting system and gathering system I implemented to just the two first workers.So my question is: If I can make one object into multiples and have each multiple have a different ID, and if so how?
Is there a way to do this to variables to?
The concept behind conditions (in events) is that there are “selecting” the objects (which match the condition) so that the actions will only act on them. So, you can differentiate objects like that (and there are conditions for variables).
For example : if you put a condition “The cursor is on object myWorker” in an event, every actions of it will act on the myWorker which is under the mouse.
wiki.compilgames.net/doku.ph … s_concepts (see Object selection by events section)
You should indeed look at the wiki as victor hinted, or browse examples: objects are selected by the events using the conditions, and actions are only applied to objects fulfilling the conditions.
So I get the concept of “Object selection by events”, but does that mean that there is no way to duplicate an object with a different ID(created in game)?[for example]
Main_Obj_0(This will be the preset object call it the “master object”) —> Event: Create new object Main_Obj_1(This will be the in game generated object, call it “duplicate_1”)
So as you can see we duplicated the name and properties of “master object”(Main_Obj_0) but added +1 to the name “duplicate_1”(Main_Obj_1), making it’s ID different yet still containing all the properties.
Am I making sense?..
You can still use a variable (object’s variable) to distinguish between instances, and then use the condition to test an “object’s variable” (under All objects > Variables) to select it in events.
On a side note : when you create a new instance with the “Create an NNNN at X, Y”, this newly created instance is automatically selected so that next actions will do their job on it (so you can set an ID after).
Thanks for the idea I was actually just looking at object variables…
And since I am already typing does any one know what the “Create an object from its name” action do?
Again thanks for the idea, victor
It does the same as “Create an object”, but instead selecting the object, use a string. This way you can create dynamically objects of different types
For example, save different objects names in variables, select one variable randomly, and create the object from the string saved in the variable
Thanks for the explanation, I guess my question is solved…