Select same object in an action based on instance variable

Get help using Construct 2

Post » Wed May 03, 2017 11:57 am

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

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!
ImageImageImageImage
B
30
S
9
G
7
Posts: 245
Reputation: 5,602

Post » Wed May 03, 2017 5:18 pm

bump...
ImageImageImageImage
B
30
S
9
G
7
Posts: 245
Reputation: 5,602

Post » Wed May 03, 2017 7:25 pm

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.
B
71
S
30
G
25
Posts: 984
Reputation: 19,503

Post » Wed May 03, 2017 8:07 pm

Magistross wrote: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?
B
30
S
9
G
7
Posts: 245
Reputation: 5,602

Post » Wed May 03, 2017 8:25 pm

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.
B
71
S
30
G
25
Posts: 984
Reputation: 19,503

Post » Wed May 03, 2017 10:03 pm

Magistross wrote: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...
ImageImageImageImage
B
30
S
9
G
7
Posts: 245
Reputation: 5,602

Post » Thu May 04, 2017 11:34 am

Share a simplyfied capx.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Thu May 04, 2017 4:19 pm

99Instances2Go wrote:Share a simplyfied capx.

Here it is: https://www.dropbox.com/s/iaatg7g92fsw0 ... .capx?dl=0

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 :)
ImageImageImageImage
B
30
S
9
G
7
Posts: 245
Reputation: 5,602

Post » Thu May 04, 2017 6:31 pm

That chain is not that difficult.
This is using a family, hope you are licensed.

https://www.dropbox.com/s/uwqn54ogqj7zq ... .capx?dl=0

Notice that also the hook has now physics.
Event 6 is rough raytracer.

I have no idea where you go from there.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Thu May 04, 2017 7:32 pm

99Instances2Go wrote:That chain is not that difficult.
This is using a family, hope you are licensed.

https://www.dropbox.com/s/uwqn54ogqj7zq ... .capx?dl=0

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" ?
ImageImageImageImage
B
30
S
9
G
7
Posts: 245
Reputation: 5,602

Next

Return to How do I....?

Who is online

Users browsing this forum: Artcadev, brunopalermo, ST314 and 21 guests