0 Favourites

Select same object in an action based on instance variable

  • Hey, I got this object that spawns a single sprite object multiple times and places them at the end of the chain.

    img:

    The object has an instance variable (called "ID") which is set to the previous highest value + 1 (so the first will have a value of 1, the second 2 and so on)

    Now, after each instance of the object is created, I want to create a Physics "revolute joint" between the newly created one and the previous one, but I don't know how to select them in one action...

    I have seen some solutions on the forum involving multiple families and adding each object to a family, but as I don't know how many chain objects there will be, I don't think it'll work.

    So, is there any way of making it work?

    Thanks in advance!

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • bump...

  • It's not possible... unless you use a family. You could then create the joint on an instance of the link to another instance of the family.

  • It's not possible... unless you use a family. You could then create the joint on an instance of the link to another instance of the family.

    Didn't really understand what you meant, could you explain it again?

  • You need a "dummy" family, with only your chainlink sprite. In a single event, you would now be able to select two distincts instances of the same object. One through the family, one through the object directly.

  • You need a "dummy" family, with only your chainlink sprite. In a single event, you would now be able to select two distincts instances of the same object. One through the family, one through the object directly.

    Yes, but the objects aren't created at the start of the layout, so I can't add them to the family from the editor and I haven't found a way to add a new member to a family via code...

  • Share a simplyfied capx.

  • Share a simplyfied capx.

    Here it is:

    The first chain would need to be linked to the Player's image point 1, the last chain needs to be linked to the GrappligHook_End sprite, and all the others to each other in order of their "ID" instance variable.

    Hope I explained it well enough

  • That chain is not that difficult.

    This is using a family, hope you are licensed.

    Notice that also the hook has now physics.

    Event 6 is rough raytracer.

    I have no idea where you go from there.

  • That chain is not that difficult.

    This is using a family, hope you are licensed.

    Notice that also the hook has now physics.

    Event 6 is rough raytracer.

    I have no idea where you go from there.

    Awesome, thank you very much!

    Also, what did you mean with "I have no idea where you go from there" ?

  • Looks like the base for a platformer. Not so sure how to combine platform with physics. I have not done that myself yet.

  • Looks like the base for a platformer. Not so sure how to combine platform with physics. I have not done that myself yet.

    It's not quite a platformer... it involves swinging, but that's about as much as I can say before it's done =D

    As for the physics platformer, that's pretty easy, you add only the physics behaviour and simulate the platformer behaviour with it (apply force left/right to more, apply impulse upwards to jump)

    From my limited experience, the two behaviours don't work to well together so this is a way to get past that...

  • Have fun coding that !

  • Have fun coding that !

    Heh thanks.

  • Here's what I meant by "dummy" family.

    It's far from perfect but it's something to build upon.

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