Create object with name [RESOLVED]

Hello all,
I want to create 3 different instances of the same object and manage them independently.

I thought that the solution is: create object with name but it doesn’t work.
With this command:


the first action doen’t create the object
the second action create the object

Can you help me to use “Among object, create object named…” command correclty ?

Thanks

I don’t know if this is possible, but what I do is add a variable id to each object so then you know which object is in use.
For example
Create object Player at position 200;200
Do =1 to variable id of Player
Create object Player at position 200;200
Do =2 to variable id of Player
Create object Player at position 200;200
Do =3 to variable id of Player

Then you check for id value. That will do the trick

Try to understand:
on begin of screen
I create the object and popolate the object variable with 1 (first instance)
I create the second object and popolate the object variable with 2 (second instance)
I create the third object and and popolate the object variable with 3 (second instance)

In this case the first one is valued with one, the second with 2 and the third with 3?
Is it correct ? Why when I popolate the second time the variable the first instance is not affected ?

Thanks a lot,
J

Hi,
The command create among allows to create an instance using string expressions.
If you have objects: obj0, obj1, obj2 and obj3, you can then use “Create “obj” + Random(3)” and it will create one of the obj objects.

yes you are right in all questions.
The variables are unique per instance, so the value es different per object.
So when you want to search an object do a repeat for all objects player
then check value of player variable id and do what you need

1 Like

I don’t understand .
In create object I can insert the object name. In create among I can insert the object name and a string. But the object isn’t generated in my case.
Have I to called it “Player01” in case I wont to create an insance of Player ?

Thanks.
P.S. your picture is amazing

The command create among is NOT to choose a name for instances, it is used to create instances by calling objects using string expressions.
You cannot change the name of objects, but you can assign object variables to tell instances apart, as explained by @xisco.
I agree it’s not very clear, I had trouble with this as well, when I started.

2 Likes

OK, I understand now.
Unfortunately the help button sent me on a generic page to create the object.

I’ll try during the week-end and let you know.

Thanks a lot for your help

WOW,
it works !!!
Thanks a lot.

1 Like