How do I pick a member from a family

Get help using Construct 2

Post » Sat Nov 15, 2014 2:41 pm

Hello again.
Could someone please help me out.

I have a bunch of different coloured blocks on the screen, each block has the variable "Name".
So I have ORANGE, BLUE, YELLOW, RED, GREEN.
Each block is part of the family "Blocks"

What I need to be able to do is pick out the block "named" say, RED from a bunch of other blocks and move it. How do I go about picking the RED block?

I've tried:
SYSTEM>Pick Blocks where Block.Name = "Red" > (Action>) Blocks>Set position (190,150)

But that resulted in moving ALL the blocks from the family to 190,150!

Cheers.
B
7
Posts: 33
Reputation: 341

Post » Sat Nov 15, 2014 3:03 pm

You'd have to post your code, as the test should pick nothing if the Name is not "Red".
ImageImageImage
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494

Post » Sat Nov 15, 2014 5:05 pm

is that case sensitive? Although it normally should result in nothing getting picked, if no match is found.
Did you create the blocks in the same event beforehand? Iirc back in my time when I was more active with Construct, that messed up picking of objects sometimes and I had to put picking stuff in an extra event.
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 788
Reputation: 3,788

Post » Wed Nov 19, 2014 5:18 pm

Can you not just use the UID?
Image
B
9
S
3
G
1
Posts: 346
Reputation: 1,560

Post » Wed Nov 19, 2014 5:51 pm

You just need to have "Families" of all the colors separtely:
1) ORANGE
2) RED
3) YELLOW
etc.

Then, Add all the Red blocks to RED, and so on.

In Programming Actions: select the family RED.set position(190,150) that way only the red blocks will be moved. You can also specify which red blocks you want among them to move by adding another Condition to it.

Note: You can then have another Family named "Blocks" with ALL the blocks, if required.
Last edited by Hasan999 on Wed Nov 19, 2014 6:04 pm, edited 1 time in total.
B
10
S
2
Posts: 109
Reputation: 982

Post » Wed Nov 19, 2014 5:59 pm

It seems to me that your are filtering the family ("Blocks") by doing a pick by evaluate on the objects ("Block"). Your name variable isn't a family variable is it ? If I understand correctly, your condition pick all family instances since at least one "block" has its Name variable set to "RED".
B
71
S
30
G
25
Posts: 984
Reputation: 19,503


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 42 guests