How do I know which instance has which IID?

0 favourites
From the Asset Store
If you understand BRAAAM then you know exactly what inspires this epic sound library.
  • GeometriX's example of how to select a clicked instance is good. If you can't open it, though, take this capx. It appears that GeometriX is using the latest beta version, so I just reverted it back to the release version of Construct 2, which you probably have.

    dl.dropbox.com/u/117529592/Construct%202/Forum%20questions/temp/bluegreen.capx

  • yes I understand that but reason I asked was I have another issue.

    I'm doing a multiplayer game I have the server working I have the connection working. upon connection it sends facebook info to the server which then retrieves their profil from MySQL and then will send back a series of indexes.

    it would look like

    B:0:0:1:0:2:10:3:2 etc (32 pairs in total)

    I then need to take the pairs eg 2:10 and set sprite 2's frame to 10

    that's the part I can't figure out how to manually "pick" a sprite instance.

    I can set an index variable on the sprites instance variables but how to pick the sprite with index 2 then set animation frame to 10 is where I can't find any documentation

  • briermay you should have provided that information up-front. Also, I know you probably don't want to hear this, but perhaps your first game shouldn't necessarily be one with multiplayer features. I suggest that you learn the basics first. At least read through a few more manual entries and tutorials.

    Picking nth instance in the manual.

    You say you can already read the index and apply it to an instance variable (let's call it varIndex), that's good. From here you'll do something like Pick nth instance (object.varIndex) -> set animation frame (10).

  • Pick Nth instance

    Pick the instance at a given place in the internal list of picked objects. This is most useful used in sub-events to act on separate instances. For example, in a "Sprite collided with Sprite" event, Pick 0th instance and Pick 1st instance can be used to act on each instance involved in the collision separately.

    as quoted by the link gives very little detail so I had no idea that was what it was for but thank you.

  • oh and by the way I'm not new to programming been doing it for 14+ years in Perl, c, c++ and some JavaScript just new to construct2 which I'm liking just the manual tends to be a little vague in some areas.

    I already have a fully working multi-player server that this connects to using web sockets its just the weird way construct 2 works that I'm getting used to.

  • Nobody is doubting your abilities, but as you said you are new to Construct so expect to spend some time developing your understanding of it and the way it works. Don't neglect the tutorials either.

  • This thread is probably already dead but It's in the "ball park" of what I have going on in my platform game... I totally agree with briermay in his opinion of the "vagueness" of the manual's explanation on key subjects and features for C2... With that said, I have enemy sprites on the layout... 4 with platform boxes pinned to the graphic... the manual says: "Using the previous example, if there were four TrollEnemy objects in a layout, these are instances of the TrollEnemy object type. There is only one TrollEnemy object type no matter how many instances are created. Instances all share the events and artwork for TrollEnemy. Similarly, there could be multiple instances of the OgreEnemy object type." Ok with that understood, I want my player to destroy each enemy... Individually... How can I achieve this? I've read this section of the manual back and front, and I still can't come with a solution(In C2 logic that is) to solve this problem... Again sorry for the "Thread jacking"..

    UPDATE:

    I can see that the enemy sprite (e.g. graphic) will be ok during "destroy" part of event, but the platform box attached to each will be gone forever because I do not see a "UID" for said object... Is this the main issue I will encounter on execution? When I run the game, after the first "destroy" sequence the other enemy graphic seem to behave as if the pinned box has been removed and act "wildly" ... Collisions appear to be not functioning properly...

  • You can use Containers to tie two objects together. It's great that you are reading the manual, but you should try some of the tutorials also. You can also post a CAPX of what you have so far, and the current problem, and people will be all to happy to help.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • blackhornet

    Thank you for the reply! I'm assuming Containers are available for use in the "free" version of C2? I'm kinda new to this Editor, but the potential it can unlock is well worth the grind I'm going thru... And yes , I have taken a look at several forum post(s), tutorials and links(provided by Ashley and Kyatric)... A lot of helpful information on all kinds of awesome features, like respawning enemies, high scores tally, and health bar counters... but nothing on my topic of multiply instances(with sprite box pinned; platform behavior attached) all on the layout at system start of layout... I can see the instances all 4 have different UID(s), but the sprite box(platform behavior) all 4 of those "do not" have UID(s) in the properties bar... so that's where I'm stuck at that point... Kyatric's link to "Frequently asked Questions" is a tremendous help... It gives me great ideas for other games I want to fiddle with, but I'd really like to get this problem nipped in the proverbial "bud" so to speak...

  • Simple way would be to add them into container and create 'on created' pin to - event. No uids or iids needed :)

  • 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?

  • Rable what exactly is your issue? i.e. what is it you can't do?

  • 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.

  • 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: [quote:oxkdu5i0]- Is IID dependent on the # of instances on layout or on the project? No informations on that point in the manual...

    ot 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"

  • 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?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)