How do I check location of object in Family?

Just started using Construct 2? Post your questions here

Post » Mon Aug 17, 2015 12:23 pm

Hi everyone,

I have 3 objects in a family and I randomly spawn 30 of them on the map. I want to be able to determine the location of all the objects on the map.


Thanks
Last edited by mrneko on Tue Aug 18, 2015 1:21 pm, edited 1 time in total.
B
23
S
10
G
2
Posts: 104
Reputation: 3,071

Post » Mon Aug 17, 2015 1:38 pm

Wouldn't this work?

family1 on collision with family1
> family1 destroy
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Aug 18, 2015 1:23 pm

@LittleStain

I think I stated it wrongly in my original question. I already changed it to be clearer. I want to be able to get the location of each object of the randomly spawn objects from the same family and record them in an array.
B
23
S
10
G
2
Posts: 104
Reputation: 3,071

Post » Tue Aug 18, 2015 1:39 pm

Depends what you will do with the locations. You get all the XY positions to an array if that's what you mean for later use.

The use. Call a function to do it when you want.

On Function Name > Set the array size to: "Family.Count, 3, 1"

Then subevent:
For each Family
Set value at (loopindex, 0) Family.X
Set value at (loopindex, 1) Family.Y
Set value at (loopindex, 2) Family.UID

Now all the the XY locations will be saved to the Array if you want to use them later, and you can pick them again by using UID.
Last edited by tunepunk on Tue Aug 18, 2015 1:44 pm, edited 1 time in total.
Follow my progress on Twitter
or in this thread Archer Devlog
B
42
S
18
G
19
Posts: 1,058
Reputation: 14,050

Post » Tue Aug 18, 2015 1:42 pm

@tunepunk

Thanks for the explanation. How about if I only want to get the location the object that is overlapped?

Currently I have

On Start of layout, set array (0,0) t family.X and array (1,0) to family.y

family is overlapping family: set array (0,1) to family.x and array (1,1) to family.y

I know the event doesn't look right. I want to be able to record the overlapped object's location in the (0,1) (1,1) array.
B
23
S
10
G
2
Posts: 104
Reputation: 3,071

Post » Tue Aug 18, 2015 1:49 pm

I think if would be easier if you added a Bolean instance variable to objects that are overlapping. for example "IsOverlapping".

If Family is overlapping Family. Set boolean to "isOverlapping" True.

If you want to save all the overlapping objects to the array.

On Function Name
Pick Family by compare (IsOverlapping = 1)
> Set the array size to: "Family.PickedCount, 3, 1"

For each Family, isOverlapping = 1
Set value at (loopindex, 0) Family.X
Set value at (loopindex, 1) Family.Y
Set value at (loopindex, 2) Family.UID

Hope that helps.
Follow my progress on Twitter
or in this thread Archer Devlog
B
42
S
18
G
19
Posts: 1,058
Reputation: 14,050

Post » Tue Aug 18, 2015 2:10 pm

@tunepunk

I will try it. Still a bit confused though.
Last edited by mrneko on Wed Aug 19, 2015 7:27 am, edited 1 time in total.
B
23
S
10
G
2
Posts: 104
Reputation: 3,071

Post » Tue Aug 18, 2015 3:32 pm

Hmmm. I think you need to specify an UID. On DragDrop2 start, save the UID also to the array of the tile that you are picking up, and on release the same thing. Then on "Swap" specify the same UID as well.
Follow my progress on Twitter
or in this thread Archer Devlog
B
42
S
18
G
19
Posts: 1,058
Reputation: 14,050


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests