How do I / Multiple Enemies / Familes / State Changes

0 favourites
  • 5 posts
From the Asset Store
State Machine
$10.99 USD
State Machine is a great tool for managing the state of anything in your game.
  • 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...


  • 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

  • Thank you for ur fast reply

    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?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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)

  • 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

    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

    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

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)