Checking the variables of two instances

Get help using Construct 2

Post » Sun Jan 12, 2014 4:35 pm

Hi, sorry if this is a noob question.

I am trying to make a stealth game in scirra and sort of got stuck at implementing a feature where an enemy discovers another enemy that is dead.

My enemy object uses line of sight behavior to see things.
Their movement behaviour is determined by an instance variable which they all share -alertMode.

Alert mode=0 - enemy is inactive
=1 - enemy is patrooling
=2 - enemy is alret and attacking
=3 - investigating/ alert- looking for player
=4 - enemy is dead (you need to hide the body)

So we have two instances of the same object - enemy.
One has alert mode=1 (patrooling), the other is dead (alert mode 4)

How do I tell the patrooling enemy to change their alert mode to 3, when they have line of sight to a dead enemy (4).


blurymind2014-01-12 16:35:49
B
38
S
14
G
4
Posts: 426
Reputation: 5,686

Post » Sun Jan 12, 2014 4:41 pm

Something like this?

put the enemy in a family

for each enemy
enemy alert mode =1
enemy has line of sight on family
family Alert mode = 4
- enemy set alert mode to 3
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 » Sun Jan 12, 2014 5:02 pm

[quote]family Alert mode = 4[/quote]

I cant access the enemy object variables through the family.
They are not listed in the
"compare instance variable" condition found in the "enemies" family.
blurymind2014-01-12 17:02:37
B
38
S
14
G
4
Posts: 426
Reputation: 5,686

Post » Sun Jan 12, 2014 5:04 pm

I guess a dead enemy has a different animation from a living one, right?
So you could check for animation. :)
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 » Sun Jan 12, 2014 5:07 pm

or give the family the instance variables..
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 » Sun Jan 12, 2014 5:10 pm

the problem is that both enemies are the same object and I dont know how to tell construct to compare their instance variables.

How would you do it with animation frame condition instead of family? :)
B
38
S
14
G
4
Posts: 426
Reputation: 5,686

Post » Sun Jan 12, 2014 5:13 pm

The easiest way is to do it with family.
Just check the animation frame of the family.
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 » Sun Jan 12, 2014 5:21 pm

is there a way to keep the animation code separate from the behavior code?
:)
Should I move the alert mode variable to the family and remove it from the enemy object inside the family?blurymind2014-01-12 17:22:07
B
38
S
14
G
4
Posts: 426
Reputation: 5,686

Post » Sun Jan 12, 2014 5:25 pm

Yes, it would probably be easiest to do that.
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 » Sun Jan 12, 2014 5:43 pm

damn, I cant get it to work that way either. :(
Something must be wrong in the way I am going it
B
38
S
14
G
4
Posts: 426
Reputation: 5,686

Next

Return to How do I....?

Who is online

Users browsing this forum: mikehive, plinkie and 6 guests