How do I make object pinned to each thing?

Get help using Construct 2

Post » Sun Dec 28, 2014 9:24 pm

I want for example to pin each sword to each knight.
When I say: For each Knight, For each sword, on start of layout- sword pin to knight It doesn't work. Why?
B
6
Posts: 56
Reputation: 366

Post » Sun Dec 28, 2014 9:49 pm

If you have a sword created for each knight and placed over the necessary pin position it will work. So you need to make sure there's a sword present. You can either spawn one at the start and then pin it OR have a container for the knights and place a sword in there, in that case you only need to set its location correctly and then pin it.
B
19
S
6
G
7
Posts: 1,101
Reputation: 6,146

Post » Sun Dec 28, 2014 10:26 pm

What do you mean by "container"?
I have many the same sword for many the same knights
B
6
Posts: 56
Reputation: 366

Post » Sun Dec 28, 2014 10:31 pm

Container behaviour - let's you kinda group objects.
B
19
S
6
G
7
Posts: 1,101
Reputation: 6,146

Post » Sun Dec 28, 2014 11:58 pm

If you don't want to use containers then you need to assign a sword to each knight by each sword UID as a knight object variable. That way you can do a For Each Knight and pick sword by UID.
A big fan of JavaScript.
B
76
S
20
G
73
Posts: 2,244
Reputation: 45,962

Post » Mon Dec 29, 2014 12:18 am

NormalOne wrote:For each Knight, For each sword, on start of layout- sword pin to knight It doesn't work. Why?


Could you post code that is closer to actual C2 code? The above logic is not possible. Even if I remove the 'on start of layout' part, it looks like you're assigning *all* swords to each knight.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Mon Dec 29, 2014 12:46 pm

dont use For each, but u must have same number of sword and knight.
(container will do the job,search manual about it)
B
17
S
4
G
1
Posts: 203
Reputation: 1,583

Post » Mon Dec 29, 2014 12:55 pm

to make this simple, put the sword over the knight


+sword is overlapping knight
+for each sword
+for each knight
->pin sword to knight

you can access the sword of each knight by using "pick by comparison" like this

Pick sword which
Knight.UID
=
Sword.pin.pinnedUID
B
16
S
7
Posts: 301
Reputation: 2,726


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 9 guests