How do I kill characters off one by one ?

Get help using Construct 2

Post » Sat Apr 18, 2015 6:29 am

Say if i want to kill a character, via pressing the key "x"; how to i prevent it from killing all the respawned characters at the same time?
As in I would like to kill them off one by one!

Any help is appreciated(:
B
5
Posts: 3
Reputation: 243

Post » Sat Apr 18, 2015 7:02 am

You need a method to refer to that one particular object.

Either by its UID, or by some instance variable given to them, and then use the "pick" method to pick your object.
Who dares wins
B
56
S
15
G
18
Posts: 1,846
Reputation: 17,793

Post » Sat Apr 18, 2015 8:21 am

A simple

on x pressed
system pick random character
> destroy character

would do.

If you want to specify which character to destroy first, you should create a condition so the computer knows which one you mean.
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 » Sat Apr 18, 2015 10:15 am

Thanks for the replies guys.

Yeah, the difficulty i'm facing is creating a condition to so that the computer kills the earliest spawned character.
I've been trying to figure out the UID and IID. But i'm still stumped. Heh
B
5
Posts: 3
Reputation: 243

Post » Sat Apr 18, 2015 10:25 am

There are probably much easier solutions,
but workaround for that could be something like this:

Give the character an instance variable "number"

character on created
> character set variable "number" = character.count

character on destroyed
pick all characters
(- for each character)
> character set variable "number" - character.number-1

on x pressed
system pick by comparison - character.number = 1
> character 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 » Sat Apr 18, 2015 10:34 am

Yes, there is an easier solution:

[your triggering event]
--pick enemy with enemy.iid = 0: destroy
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 787
Reputation: 3,786

Post » Sat Apr 18, 2015 10:42 am

mindfaQ wrote:Yes, there is an easier solution:

[your triggering event]
--pick enemy with enemy.iid = 0: destroy


You're quite right..
I knew there was something like that, haha..
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 » Sat Apr 18, 2015 2:28 pm

woohoo. thankyou mindfaQ for the tip, it works! and thanks to everyone who replied.
B
5
Posts: 3
Reputation: 243


Return to How do I....?

Who is online

Users browsing this forum: delgado, ketramtu18 and 1 guest