Get object type in a family event?

Get help using Construct 2

Post » Wed Jul 19, 2017 4:50 pm

Hi everyone,

Was working with families in C2, and began to wonder if there's a way to know the object type from a family event. For example, say we have the family Enemies with the sprite objects Enemy A, Enemy B, Enemy C, and I have the event "On Enemy collision with Player". I'd love to be able to add a sub-event along the lines of "if Enemy.type = "EnemyA"", but I'm not sure if there's any attribute like Enemy.type.

Of course, I could do this with a family instance variable, but I was wondering if there was any way to do it with system attributes.

Thanks in advance!
B
16
S
5
Posts: 41
Reputation: 1,156

Post » Wed Jul 19, 2017 4:58 pm

Hi .
Actually you can't ! but you can compare something like height,width,animation frame name or ...
B
18
S
8
G
2
Posts: 48
Reputation: 2,504

Post » Wed Jul 19, 2017 5:06 pm

Actually there is trick you can use. Use "pick by UID" on each object you want to test, using the Family UID. Only the correct object type will succeed.
ImageImageImage
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494

Post » Wed Jul 19, 2017 11:14 pm

Interesting trick! Thanks for the help :)
B
16
S
5
Posts: 41
Reputation: 1,156


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 48 guests