Setting IIDs based on IVs

0 favourites
  • 6 posts
From the Asset Store
Advanced inventory mechanics for your RPG game (Array-based). Take Items, split them, pick up them, read the description
  • I'm sorry, I'm a little out of it and despite reading a good deal on IIDs in the manual and throughout the forums, today just isn't the day for my brain to be especially adaptive.

    I'm trying to set the IIDs of an object's instances based on its x-coordinates.

    E.g.

    Object1 X=60 ---> set IID to 1

    Object1 X=150 --> set IID to 2

    and then..

    Object1 IID=1 --> set animation frame to 0

    Object IID=2 ---> set animation frame to 1

    et cetera.

    I understand I might need to use instance variables and/or [though hopefully not] nth instances, as referred to in the manual:

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

    If all objects are currently picked, this condition can also be used to pick an object by its index ID (IID). For more information, see common features."

    Anyways, I'm going to go be active for a bit in an attempt to rejuvenate myself. Any assistance here would be appreciated.

    Thank you!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hey Teahouse,

    To quote Ashley in a prev post,

    "IIDs are not constant - they change as you destroy and create objects, so you can never be certain that an IID refers to a specific instance.

    You probably want to use UIDs instead, which permanently refer to a single instance."

    But to take a stab from a different angle you could try to set variables for the objects once they pass a point by laying down invis sprites and then using "Object is overlapping Sprite - Set animation frame to X".

  • That's an interesting idea, thank you GenkiGenga. Unfortunately, I don't think it will work, as I suspect that setting animation frame to X under those circumstances will lead to all of said 'objects' instances changing frame in response to that event.

    But I will give it a shot and report back!

    Also, looking forward to checking out your portfolio site!

  • The easiest way to fix this, I think, is to simply import each frame as a separate sprite. I was just hoping to avoid that.

  • Outstanding! Your recommendation works!

    I clearly have a good bit more to learn with regards to interactive elements in C2.

    Thanks again!

  • No worries!

    By the sounds of things you'll be catching up pretty quickly. I'll keep you updated about the site ;)

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