How do I make separate enemies behave independently?

0 favourites
  • 9 posts
From the Asset Store
Pixel Enemies for SHMUP
$3.50 USD
30% off
Pixel Enemies for SHMUP consists of 45 enemy ship sprites to be used in your game.
  • Hi everyone,

    I have made an "enemy" in my game. It has various events that work fine while I only have 1 in the layout. But when I add another they seems to share some behaviors. For example, if you one has line of sight, so does the other and events that are triggered effect both, instead of just the one with LOS. I noticed "Families" in the project area, and was wondering if i have to use that, or if there is another way to make the "enemies" at in dependently. After looking in the manual "families" seem to be the easy way to do this. If you need more info just let me know.

    Thanks,

  • I am not sure if families are available on the free version of Construct 2.

    Anyhow, I guess you are using instances of the same object and that is why they behave the same. You can either:

    1) Create a separate entity (clone object type) so that they'll be totally independent from each-other

    2) Create an Instance Variable (perhaps a text so to give your enemies names) and in the event sheet create conditions that check (compare) the Instance Variable (name) and add actions accordingly for each enemy.

  • Thanks eli0s,

    Families are a paid feature. I am considering buying the personal version, especially if it saves me work .

    I read the docs on instances and instance variables and thought that each instance tracked its own variables. Maybe I misunderstood.

    I've been using a path finding a line of sight tutorial to get some of my events working. I noticed they have a For each loop for the enemies. I tried to use that but couldn't figure it out initially. Think that could help?

    I'm trying to avoid making events for each instance. If thats one of the limitations of the free version, I'll probably get the personal license.

  • C2 picks all instances unless you choose otherwise. Probably faster to post what you have so someone can have a look. Families won't help in this case.

  • Use System: For Each (object name)

    and also use the instance variables' values as conditions.

    Somewhere in your events, you have to randomize OR use another way to put different values in each instance variable of each object instance, because otherwise, using "for each" would be pointless.

    families is for grouping different objects together.

    Family "ENEMY" would include: Soldier object, Boxer object, Swordsman object, etc.

    Based on your description, For Each is what you need, not families. Read more about For Each in the manual.

  • Thanks for the feedback. I haven't had time to dive into the "For each" but I'll give that a try. Here is my (very simple) game at the moment. The "enemies" are supposed to act kinda like zombies, but I don't want them to act together (at least not right now).

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hmmm... It's more complicated than I expected. I like what you already have set up. I can't figure out how to make the instances behave separately with an Instance Variable and the "For Each" loop gives me an error at run time.

    The only thing I am confident that it will work is to use different objects for each enemy, but this isn't very practical if you have a lot of enemies. Actually, it's rather dumb...

    Perhaps an advanced forum member can help here..?

    I am sorry for not being able to help

  • Thanks for all the responses. I was able to get the "For each" loop to work ( or at least do what I needed). I have found other things that I need help on now, so I'll make a new post. Here's what I game file incse anyone else is doing something similar and can use it. Just FYI there aren't comments, and there are some disabled chunks. But feel free to PM me if you need help deciphering it lol.

  • Here is a small update. I removed the "For Each" to get some other stuff to work. I wanted the enemy to stand still and "attack"(once I make animations). So now they will stop and rotate towards the player when overlapping him. I found that sometimes they would run through the player and then lose sight of him. Since my enemies are supposed to be like zombies, I felt that they wouldn't just run by fresh meat because they missed .

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