How do I ....Spawn the same sprite but give it a unique ID

0 favourites
  • 5 posts
From the Asset Store
Minimal Sprite Font with Stroke for Pixel Art games.
  • Hi,

    I currently have a game in development where I spawn a certain sprite every 10 seconds , this works fine but I want each sprite that is spawned to have its own unique ID.

    So then I can, for example , see if one of the sprites collides with a certain object, that only that one is destroyed and not every instance of that sprite.

    Can I make it so everytime the sprite is spawned it has its own unique reference or name.

  • Every sprite has already an unique ID. shortened as UID. You can retrieve it in the expression Sprite.UID

    It is unique during run time. It can rearrange during designing, when you going to create/destroy sprites in layout editor.

    You can also give a sprite an instance variable. Give it a accumulating value during run time. Or give it values in the layout editor.

    Both are intensive used. But not (or very rarely) in the way that you mention.

    Using the condition Sprite > 'On collision with another object' will PICK both (instances of) objects, and only those objects.

    The actions work on the picked objects.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yeah , its just I have a sprite being duplicated every x Seconds, but if one instance of that sprite collides with an object , I want to destroy that sprite only and not other instances of it on screen :/

  • That's how it works by default unless you have something funky going on in your events. Can you post your capx or a screenshot of the event sheet?

  • Never mind man ! Thanks for you help , ive worked it out now haha!

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