How do I / Multiple Enemies / Familes / State Changes

Just started using Construct 2? Post your questions here

Post » Wed Dec 17, 2014 4:51 pm

Hi there,

I have some issues creating multiple enemies of same type reacting different for each...

I read the forum topics for days and hours - same thing happend to the manual but i couldn't really find an answer for my problem. At least - it's all about the "ForEach" Condition, isn't it?

I wanna explain short.
Each enemy is a sprite. Each enemy sprite is assigned to the Family "Enemies". The Family "Enemies" has different Variables and Behaviors set. Each Enemy, as a child of Family "Enemies", will earn these Var. and Behaviors. Each Enemy within the Family is triggered by different AI Code in the same way I attached to this post.

For now, every Enemy will move independently and Health will be calculated correctly, as far as I can see... But, for example, I have some effects assigned to the Family "Enemies" which are triggered on collision with my players bullet which almost works too but sometimes the enemies wont react correctly. Almost the Enemys Instance #0 doesn't react properly. Although, I have 4 Types of the same Enemy on screen - 3 of them die - 1 stays alive but won't react in any way.

For sure I tested a thousand ways last days and watched each Enemys reaction due to each change I made within my coding stuff... Now, I'm really really confused about what to pick, when to pick, where to pick - nick ... Pls tell me, if someone know - what am I doing right - where are things going to be wrong...

Cheas
You do not have the required permissions to view the files attached to this post.
B
5
Posts: 15
Reputation: 255

Post » Wed Dec 17, 2014 5:42 pm

Don't mix families and its members in your events. In your example, make all those booleans and behaviors part of the family.

Use variables to differentiate between types of enemies. You can add a variable "id" to the family, and each type of enemy will have a different id, which you will use in the events
B
84
S
22
G
15
Posts: 1,039
Reputation: 15,249

Post » Wed Dec 17, 2014 6:11 pm

Thank you for ur fast reply :D

I changed some things due to ur hint. ... I also added 2 more Enemies inside the event for testing purposes just the way I added the "Jumper".

Seems to work but I didn't test it for long nor in depth.

Am I using those "For each" correctly as a upper level event and seperate each enemy by name in a subevent without any following "ForEach"... ? Is this a common way to call AI and adress to the correct foe? Isn't it easier or maybe more stable to pick each Enemy by its own UID ? And if - do I have to pick by comparsion comparing the UID I insert while "Enemies - OnCreated" or is there a more common way?
You do not have the required permissions to view the files attached to this post.
B
5
Posts: 15
Reputation: 255

Post » Wed Dec 17, 2014 6:32 pm

This is the correct way as far as I know.

On the first event though, you don't need a "For each". That green arrow is a good indicator that that action will pick only that one object

On event 220 you still have an action on Enemy_01 and that wont work. Since the condition is picking the family object, it won't know what Enemy_01 to pick, so it will affect every Enemy_01 (it's a mistake that I frequently make)
B
84
S
22
G
15
Posts: 1,039
Reputation: 15,249

Post » Wed Dec 17, 2014 7:20 pm

Oh yeah u are right ... I missed this to change - but due to testing I took two other enemies with kinda more complex events... Whatever :P

Things seem to work - somehow ... Some things do work, some do not - for example - I cant assigne State Effects like being Freezed to every Enemy - almost instance#0 wont take advantage of this while other instances are freezed. And, if those instances aren't freezed anymore I can freeze #0 but now, an instance other than #0 wont take effect of its state being changed. But the whole movement and shooting and whatever works properly, as far as I can debug right now.

But still - after this rework, I gonna pick correct instances I guess. Now I gonna figure out what the state change problem is - as I can exclude my freakin' instance picking as an option of being terribly wrong... like my english haha :P But still, it is :D

If someone has an idea why I got this problem assigning several state effects to enemies ... you are welcome?

But - so far - thanks a lot for ur help :D
B
5
Posts: 15
Reputation: 255


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest