How do I select a family instance this way?

Get help using Construct 2

Post » Tue Jun 19, 2012 8:17 pm

Greetings !

I'm just wondering how I could tell construct to create a weapon from my "weapon family", but only if its variable "type" is "shotgun".

I guess it's possible, but I didn't manage to find how...
B
5
S
1
Posts: 34
Reputation: 1,026

Post » Tue Jun 19, 2012 9:03 pm

on event
> subevent compare family var type="shotgun" > create object shotgun

or

on event
for each family object
> subevent ...

not surevtrix2012-06-19 21:06:27
ImageImage
B
61
S
19
G
6
Posts: 809
Reputation: 9,028

Post » Tue Jun 19, 2012 9:16 pm

Hmm...

The thing is, I would like to avoid a "create object shotgun" action, because it means that I would like to create an action for every weapon type.

Here's my capx : test

Here, I would like each wave to create an [enemy], which have the same ID value that the current wave.enemyID.

Is that possible?
B
5
S
1
Posts: 34
Reputation: 1,026

Post » Tue Jun 19, 2012 9:44 pm

You can check the variable after a random family object has been spawned, then destroy it and spawn another one if it doesn't match the other variable.

Example: FamilyVariableSpawn.capx
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Tue Jun 19, 2012 9:48 pm

its this exact feature i would like to see for construct2, a way to create an object of a family based on a variable, this would mean that you only need one compare event and the whole system is set,

the way its now you have to compare for each object you want to create

id=1 create enemy1
id=2 create enemy2


ImageImage
B
61
S
19
G
6
Posts: 809
Reputation: 9,028

Post » Tue Jun 19, 2012 9:54 pm

@Nimtrix

thats pretty smart, however for optimal performance you should not create maybe 10 objects or more before you get to the right one, but it is a workaround
ImageImage
B
61
S
19
G
6
Posts: 809
Reputation: 9,028

Post » Tue Jun 19, 2012 10:13 pm

Thanks for your replies. I guess Construct 2 lacks this type of family instance selection...
B
5
S
1
Posts: 34
Reputation: 1,026

Post » Wed Jun 20, 2012 1:57 am

@Canapin

ive implemented nimtrix example, wanted to see if it would work with the generators

i changed it a bit and used a for loop, its a bit cleaner

wavegenerator
ImageImage
B
61
S
19
G
6
Posts: 809
Reputation: 9,028

Post » Wed Jun 20, 2012 9:30 am

That's stunning. I've just fixed a small mistake :
system -> set choice to wave.enemyID instead of wave.ID

That works perfectly, thanks a lot !

Now I'll have to implement the wave patterns... :D
B
5
S
1
Posts: 34
Reputation: 1,026

Post » Wed Jun 20, 2012 11:01 am

@Canapin what will the patterns do?, add some kind of movement setting to the spaceships?
ImageImage
B
61
S
19
G
6
Posts: 809
Reputation: 9,028

Next

Return to How do I....?

Who is online

Users browsing this forum: WhosWho and 23 guests