'Planet' on collision with 'Planet'?

Get help using Construct 2

Post » Thu Jan 22, 2015 4:33 pm

Hi guys,

If i had the a physics object called Planet which has different animations then setup the following event.

-'Planet' on collision with 'Planet'
--------Is animation 'default' playing? -> 'Planet' destroy.
--------Is animation 'sun' playing? -> ?????

This would give me the following results in game.
-In a planet vs planet collision both planets would be destroyed.
-In a planet vs sun collision only the planet would be destroyed.

However, In a sun vs sun collision I want both suns to be destroyed, but I don't know how to separate the two instances to compare them. Is one self and the other planet?

Thanks in advance.
ImageImageImageImageImage
B
19
S
5
G
1
Posts: 614
Reputation: 2,542

Post » Thu Jan 22, 2015 6:53 pm

Why not put the Planet in a family as well, then do the collison checks between Planet and Family(Planet).
B
50
S
16
G
9
Posts: 1,098
Reputation: 11,237

Post » Thu Jan 22, 2015 8:59 pm

@spongehammer Thank you. That is a helpful suggestion and I will probably end up doing it that way. However, I was kind of hoping for something more elegant i.e. built in functionality. If it doesn't exist then that's fine.

Edit: Gahhh... I cannot access the planet's instance variable through a family. So unfortunately that wont work :(
ImageImageImageImageImage
B
19
S
5
G
1
Posts: 614
Reputation: 2,542

Post » Thu Jan 22, 2015 9:31 pm

Here's how you could do it with a for each. Much more complicated than just using families though...
You do not have the required permissions to view the files attached to this post.
B
74
S
31
G
26
Posts: 999
Reputation: 20,208

Post » Thu Jan 22, 2015 9:32 pm

Always put important objects in a Family IMO, with the instance variables on the family
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Fri Jan 23, 2015 2:09 am

Well, a free scrub like me can't use families. You *could* probably go:
On Collide Planet (sun) -> Planet (sun)
--System -> Pick Nth Instance Planet (sun) 1 | Planet -> Destroy
--System -> Pick Nth Instance Planet (sun) 0 | Planet -> Destroy
B
11
S
4
Posts: 152
Reputation: 1,236

Post » Fri Jan 23, 2015 3:56 pm

Yup, and it's indeed easier than looping. I always thought "pick nth instance" used IID, but I was wrong ! Here's the updated capx.
You do not have the required permissions to view the files attached to this post.
B
74
S
31
G
26
Posts: 999
Reputation: 20,208

Post » Fri Jan 23, 2015 5:36 pm

@Magistross
@codah
@spongehammer
@Unnatural20

Thanks for your help guys. I actually avoided the situation in the end by creating separate objects for each type. However, I do come across this problem semi-regular so I'll be sure to try this nth instance trick.
ImageImageImageImageImage
B
19
S
5
G
1
Posts: 614
Reputation: 2,542


Return to How do I....?

Who is online

Users browsing this forum: jezjones24, Lancifer, matriax and 19 guests