# How do I oppen just one door by killing an ennemy

Get help using Construct 2

### » Tue Mar 14, 2017 8:36 pm

Hi there, i'm new to construct and i have an issue,
when i kill an enemy it open all doors when i want to just open one.
I've try to give a variable to door, the first one is 1, this second is 2 and the third is 3, when i kill an ennemy i subtract to the value of this variable 1 and i put another event, when door=0 it destroy.

but well it doesn't work and destroy it all,
if you want the .capx to take a look here it is:
https://mega.nz/#!pZpizSqA!zkn6RzO0ViJt ... G_1cK2XTko

I don't want to ask too much but i use the camera from here https://www.scirra.com/tutorials/747/zo ... a-movement
but it's just a capx and i can't figure out the math to adapt to another screen size, if anyone have a link that can help me or explained it to me ^^
B
10
S
2
Posts: 4
Reputation: 638

### » Tue Mar 14, 2017 8:41 pm

How about just assign the value itself and not deal with adding or subtracting lives?

So when enemy #1 dies, door #1 opens. Etc.
B
36
S
15
G
27
Posts: 778
Reputation: 17,697

### » Tue Mar 14, 2017 8:55 pm

yeah it would be cool, but i don't know how to do that, after the event of on destroyed i can't find anything that tell to destroy the object whith this one value in his variable.

the alternative i can think of is to create 3 door instead of duplicate them but i want to understand the other way so i can learn more ^^
B
10
S
2
Posts: 4
Reputation: 638

### » Tue Mar 14, 2017 9:37 pm

Are your doors all the same sprite or are they clones or individual sprites with different names?

If you use the same sprite for all doors then you can choose which one opens by it's UID.

If they are clones or different sprites call them to open by the assigned name.
Banned User
B
29
S
7
G
58
Posts: 1,229
Reputation: 34,900

### » Tue Mar 14, 2017 9:42 pm

B
36
S
15
G
27
Posts: 778
Reputation: 17,697

### » Tue Mar 14, 2017 10:25 pm

lamar wrote:Are your doors all the same sprite or are they clones or individual sprites with different names?

If you use the same sprite for all doors then you can choose which one opens by it's UID.

If they are clones or different sprites call them to open by the assigned name.

all my door are the same object duplicated with the same sprite, and well i don't know how to use it in event.

MPPlantOfficial wrote:Here: https://www.dropbox.com/s/g9hnzyf6tim0m ... .capx?dl=0

That's exactly what i wanted, nice exemple i get how it work so quickly ! Thank you so much
B
10
S
2
Posts: 4
Reputation: 638