How do I access family members of certain object type

Get help using Construct 2

Post » Fri Nov 21, 2014 3:24 pm

I have 4 family members

- object type: sprite, name: asteroid
- object type: sprite, name: player
- object type: sprite, name: enemy
- object type: sprite, name: obstacle

all of this four have Health Points so i added HP variable to family.



Now: when enemy shoots to player i want to take 1 hp point from player's hp, but Player object has no HP variable - HP Family has it, so i have to detect collision between bullet and entire HP family. Now enemy bullets destroy everything, obstacles, asteroids, another enemies...
The question is: how can i detect collision between enemy bullet and player and take 1 point from it's HP family instance variable.


And second question:
since Family members can't contain other objects such as HP text object - i have to create Text object in for each loop through entire HP Members family, but I don't want to create text object for obstacles in this family, because it's not important to show how much energy obstacle has left. How can i remove only obstacle object types from this loop.

Any help will be appreciated
Posts: 20
Reputation: 392

Post » Fri Nov 21, 2014 10:42 pm

You should be able to access the family instance variable on the object.

You could add the three objects that need text objects to another family and use that for text.
Posts: 1,520
Reputation: 25,780

Return to How do I....?

Who is online

Users browsing this forum: Google [Bot] and 7 guests