How do I get UID of Spawned Object?

0 favourites
  • 6 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • How do I get UID of Spawned Object?

    I want to set instance values to the object that spawned by itself.

    If you know a better solution let me know

  • What do you mean by "spawned by itself"?

    If you have sprite A which spawns sprite B, you don't need to know B.UID, you can simply do this:

    A spawn B

    B set instance variable ....

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • What I mean is Sprite A spawn Sprite A

  • You can try a trick with a family.

    Create a family with sprite A.

    Then use "FamilyA spawn A"

    "A.UID" in this event will refer to UID of a newly spawned instance.

    Or you can use "System->Create" action:

    Function call "CreateNewA" (A.x, A.y)
    
    On function "CreateNewA" 
       System-> create new A on layer 0 at (function.param(0), function.param(1))
       A set instance variable ....
    [/code:1kr5a5k7]
  • Why not just do a simple "on created --> set bla bla bla to object.uid"

    Doesn't get any easier than that.

  • Why not just do a simple "on created --> set bla bla bla to object.uid"

    Doesn't get any easier than that.

    I didnt know that condition exist till you point that out thanks alot

    You can try a trick with a family.

    Create a family with sprite A.

    Then use "FamilyA spawn A"

    "A.UID" in this event will refer to UID of a newly spawned instance.

    Or you can use "System->Create" action:

    > Function call "CreateNewA" (A.x, A.y)
    
    On function "CreateNewA" 
       System-> create new A on layer 0 at (function.param(0), function.param(1))
       A set instance variable ....
    [/code:18mvpv1v]
    

    thanks for the answer it helps a lot

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