How do I know which instance has which IID?

Get help using Construct 2

Post » Fri Oct 11, 2013 6:23 am

Simple way would be to add them into container and create 'on created' pin to - event. No uids or iids needed :)
B
24
S
8
G
7
Posts: 756
Reputation: 7,202

Post » Fri Aug 29, 2014 9:37 am

Undigging this one but I have a similar problem and hopefully just found a solution.
Could this work? :

(considering the "object" object type has an "index" number instance variable, and that there are 5 instances of "object")

at the start of layout
Repeat (5)
>pick loopindex instance of object (pick Nth)
>>set variable object.index to loopindex

From now on, you can start using the "index" instance variable as if it where the instance's IID, as it won't change throughout the layout. Not 100% sure that a loop at the start of layout will play... (anyone know?) but if it don't, it could be put in a group that triggers only one.

I also have another question : is the IID of the first instance on the layout always 0, or, if there are other instances of this object still alive on previous level, would the first instance on the current layout be more than 0?

And if it could be more than IID 0, is there a way to still give them correct "index" numbering, i.e. : 0, 1, 2, 3, 4, etc...
This would require to take the instance with the lowest IID and assign the 0 number to its index instance variable, but I have no idea how to do it... Anyone knows?
Image
B
14
S
4
G
1
Posts: 268
Reputation: 1,794

Post » Fri Aug 29, 2014 10:07 am

@Rable what exactly is your issue? i.e. what is it you can't do?
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Fri Aug 29, 2014 10:26 am

My first goal was to provide a clear way of dealing with the post's original problem : using IID in a more "durable" way.
I don't have access to C2 right now and would like feedback on the solution I'm providing : is something wrong with the logic, or is there a better way to do it?

Then I wanted to learn about things that I haven't been able to find informations on until now :
- Do loops in the "at the start of the layout" condition really loop, or just play once?
- Is IID dependent on the # of instances on layout or on the project? No informations on that point in the manual...

The actual thing I can't do : if the IID are #4, 5and 6, how can I "tag" them with a number instance variable 0, 1 and 2? i.e. is there a way to select the instances with the lowest IID on the layout, then select the next one, or the one with the highest IID, in order to be able to tag them correctly.
Image
B
14
S
4
G
1
Posts: 268
Reputation: 1,794

Post » Fri Aug 29, 2014 10:36 am

Just to jump to the end. If there are only three objects, they won't be IID 4, 5 and 6 they will be 0, 1 and 2.

Edit:
- Is IID dependent on the # of instances on layout or on the project? No informations on that point in the manual...
Not sure what you mean by this. IID is for instances, they are in index of the number of instances of an object type. So your instances will always be numbered 0 to Sprite.count - 1

Edit 2: What I was trying to get from you is "what is the problem you're trying to solve by tagging object instances relative to IID"
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Fri Aug 29, 2014 11:19 am

Thank you codah, and sorry for the misunderstanding.
My original problem was this one : (not allowed to post URLS but check post "Question about using a single event sheet on different level" - last replied wed 27th august 2014 at 6:26 pm)

What I meant with the number of instances is the following : if I have instances 0, 1 and 2 on layout 1, and I'm currently on layout 2, where there is 3 additional instances of the same object type, will they be numbered 0, 1 and 2 - or - 3, 4 and 5 (IID)
And so instances awaing for me on layout 3 will be IID 6, 7 and 8?
Image
B
14
S
4
G
1
Posts: 268
Reputation: 1,794

Post » Fri Aug 29, 2014 11:28 am

Rable wrote:Thank you codah, and sorry for the misunderstanding.
My original problem was this one : (not allowed to post URLS but check post "Question about using a single event sheet on different level" - last replied wed 27th august 2014 at 6:26 pm)

What I meant with the number of instances is the following : if I have instances 0, 1 and 2 on layout 1, and I'm currently on layout 2, where there is 3 additional instances of the same object type, will they be numbered 0, 1 and 2 - or - 3, 4 and 5 (IID)
And so instances awaing for me on layout 3 will be IID 6, 7 and 8?


While you are on layout 2, there are only 3 instances existing, numbered 0, 1 and 2. When you go back to layout 1, there will still be only 3 instances, 0, 1 and 2. Etc for layout 3. You can check this with Debug mode.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Fri Aug 29, 2014 12:10 pm

This is great news ! Thanks a lot !
Image
B
14
S
4
G
1
Posts: 268
Reputation: 1,794

Previous

Return to How do I....?

Who is online

Users browsing this forum: Callan S and 18 guests