they're everywhere -- handling multiple enemies

Get help using Construct 2

Post » Fri Sep 26, 2014 4:04 pm

so im trying to implement multiple instances of the same monster in my game, a slightly enhanced clone of ashley's snailstomper from the begginer's platform tutorial. these orcs of mine are to be a bit more complex than the snail though, so i used different sprites for the box and the animation, same as in the main char, as advised in the tutorial. everything good until i try to use two instances (crtl-click) of the same enemy...

see, it (the box) moves for and backward in its platform, gots two edge-markers to tell it when to toggle an instance variable right-left, and mirror the animation... problem is, variables dont seem to work locally X( so my orc faces the wrong direction oft as not... even worse, there's some combat commands in the event of contanct with the hero, few animations etc, some implemented by instance variables (ie the monster's health), other just by events. unsurprisingly, both (stupid creatures) are triggered at the same time: if one attack both swing their swords, if you kill one the other one dies too...

guess im doing something wrong with the variables :( but i cant figure it out. maybe this is more like a begginers question, well, its always hard to say... i thought it would get more attention here maybe :P

capx attached. hopefully. my first one whohoho. feedback welcome. battle mechanics are rudimentary, any ideas will be hearkend to. creep death animation sucks specially, even when it actually happens. yes u are immortal. so far.

thanks for your time and interest :)
You do not have the required permissions to view the files attached to this post.
B
23
S
11
G
6
Posts: 181
Reputation: 5,010

Post » Fri Sep 26, 2014 5:25 pm

I had the same problem some time ago.
using for each will solve it.

this was the topic I made back then: https://www.scirra.com/forum/viewtopic.php?f=147&t=92255
B
8
S
4
Posts: 120
Reputation: 1,266

Post » Fri Sep 26, 2014 6:03 pm

for each, uh? sounds... plausible! ill have a look.
thanks, mate!
B
23
S
11
G
6
Posts: 181
Reputation: 5,010

Post » Mon Sep 29, 2014 12:02 am

yep. works beautifully. managing both sprites (box&animation) was a bit tricky tho. here's what i came up to, maybe not the most elegant solution, but works.

Image

theres only trouble if the two instances touch each other, cos the mirror on the animation is triggered when it touches the box, so if it touches another box (with another value in the variable) it gets messy. oh, well. i can live with that.

@derqs thanks a lot dude!
B
23
S
11
G
6
Posts: 181
Reputation: 5,010


Return to How do I....?

Who is online

Users browsing this forum: Google [Bot], matriax and 19 guests