Strange family behavior

For questions about using Classic.

Post » Mon Jan 26, 2009 8:21 pm

I have the following events set up for an enemy with the platform behavior.

+Enemy.Angle = 0
++Terrain offset(10,2)
--Set horizontal speed to 100
++Else
--Enemy: Set angle to 180

+Enemy.Angle = 180
++Terrain offset(-10,2)
--Set horizontal speed to -100
++Else
--Enemy: Set angle to 0


This makes the enemy walk back and forth along the platform it is standing on. Works great! That is, until I add a copy of the enemy to the layout. Then, it no longer works until ALL the enemies reach the edge of their platform.

How can I make this work for each enemy separately?
B
2
G
3
Posts: 71
Reputation: 992

Post » Mon Jan 26, 2009 8:39 pm

Are you using the Compare Values system condition? It doesn't do ordinary object picking. It should work fine if you use the conditions within the sprite object itself to compare. Alternatively you could put a "For Each Enemy" condition above the comparison.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Mon Jan 26, 2009 9:18 pm

No, I'm not using the system compare object. I'm doing a straight-from-the-wizard enemy angle comparison.

I just tried the "For each Enemy" condition outside the whole set, and it inverts the behavior. Instead of requiring ALL enemies to reach the ledge before turning around, now as soon as a SINGLE enemy reaches the edge, ALL enemies turn around in sync.

Here's the new event block:

+For each Enemy
++Enemy.Angle = 0
+++Terrain offset(10,2)
---Enemy: Set horizontal speed to 100
+++Else
---Enemy: Set angle to 180

++Enemy.Angle = 180
+++Terrain offset(-10,2)
---Enemy: Set horizontal speed to -100
+++Else
---Enemy: Set angle to 0
B
2
G
3
Posts: 71
Reputation: 992

Post » Mon Jan 26, 2009 9:49 pm

Maybe post an example .cap so people can find a way to fix it.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Mon Jan 26, 2009 10:09 pm

Uploaded here.
B
2
G
3
Posts: 71
Reputation: 992

Post » Mon Jan 26, 2009 10:49 pm

I have responded there. In your case, the Else condition was messing the stuff up, as it picked all objects matching the first condition - is going into the same angle. Changing that to "is not overlapping terrain at offset", basically the inverse of previous condition, only picks the one that is at the end of platform and thus saves it from the certain doom, while other skeletons are still happily going their way.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 8 guests