Pin to Instance

Get help using Construct 2

Post » Tue May 15, 2012 6:01 am

Is there a way to pin instances of an object to a specific instance of another object? I'm using a dummy object to rotate the balls in a circle and I want to be able to assign balls to different rotation dummy objects.

B
8
S
3
G
4
Posts: 22
Reputation: 2,717

Post » Tue May 15, 2012 6:03 am

for each dummy
-----ball ID==Dummy ID--->ball:rotate around dummy.

If that doesn't work in C2, try this (I mostly use classic, so I'm not sure if c2 has small differences with regards to picking)

for each dummy
---for each ball
-----ball ID==Dummy ID--->ball:rotate around dummy.

alternatively you can store the dummy co-ords in 2 PVs in the balls, and get rid of the dummy objects altogether. This is less flexible because you can't manipulate the dummies around like normal objects (you need to reference the balls by ID grouping, then change all of their PVs at once), but you save on object count, which can help in a restricted environment (like phones).Davioware2012-05-15 06:09:43
B
25
S
3
G
6
Posts: 1,197
Reputation: 5,620

Post » Tue May 15, 2012 6:19 am

Sorry, I don't quite follow. I'm not too experienced on the coding side of things.

In the capx below there are 2 instances of the dummy object that are rotating at different speeds. The pin behavior doesn't allow me to specify which instance. All of the balls end up being attached to the 1st instance. I'm trying to find a way to have a 2nd set of ball rotate around the 2nd instance of the rotation dummy.


Here is the .capx
http://dl.dropbox.com/u/31346541/C2/Rotation.capxMastasurf2012-05-15 06:19:38
B
8
S
3
G
4
Posts: 22
Reputation: 2,717

Post » Tue May 15, 2012 6:21 am

Yes. Use the Pick nth Instance under the Systems option.

So, it'd be:

System | Pick Rotator instance 0
> Pin rotatingBallThings to Rotator

System | Pick Rotator instance 1
> Pin otherRotatingBallThings to Rotator
B
14
S
1
G
2
Posts: 85
Reputation: 2,810

Post » Tue May 15, 2012 6:33 am

Like this?


This didn't seem to work.
B
8
S
3
G
4
Posts: 22
Reputation: 2,717

Post » Tue May 15, 2012 1:01 pm

does this help?

capx
ImageImage
B
61
S
19
G
6
Posts: 809
Reputation: 9,028

Post » Tue May 15, 2012 4:35 pm

Yes! That helped a lot. Thank you very much for the help!

Mastasurf2012-05-15 16:40:07
B
8
S
3
G
4
Posts: 22
Reputation: 2,717

Post » Wed May 16, 2012 3:33 am

The method that vtrix shared works well. Now I'm wondering if anyone has suggestions about a cleaner way to implement the solution so that it can scale to N number of objects.

Right now there are 2 rotation dummy objects with balls spinning around them. This is how it's setup in the capx.



I experimented with some different "For Each" loops with no success. Any suggestions?
B
8
S
3
G
4
Posts: 22
Reputation: 2,717

Post » Wed May 16, 2012 7:13 pm



If you use families or just one yarn sprite with different animations for each colour then you can replace the three yarn lines with just one.
B
54
S
28
G
18
Posts: 1,520
Reputation: 24,990

Post » Thu May 17, 2012 5:04 am

That looks much much cleaner. I just tested it out and it works great.

Just to help me understand the tool better I'm wondering if someone could explain why the last loop I attempted didn't have the same result.
B
8
S
3
G
4
Posts: 22
Reputation: 2,717

Next

Return to How do I....?

Who is online

Users browsing this forum: GUN and 16 guests