How do I make two enemies move seperatly?

0 favourites
  • 10 posts
From the Asset Store
This is a Dungeon Master tool & the 1st of 12 Combat Engines from the Building Combat Engines for Browser Games workshop
  • Hello, Travis here

    Some of you may remember my other thread about getting enemies to move at all. Today I have a different error instead.

    I have successfully been able to make my enemies move around without with no issues when there is only one of that enemy on a layout.

    I have two of the same enemy now and they both keep changing which direction they are facing. I have tried looking up many tutorials but they don't help. People mention containers, families and using a for each loop, none of these seem to work so it must be an issue with my game.

    Sorry for sending a file with so many events.

    When playing the game don't move the player as the skeletons will chase you, when game starts watch the skeletons on the right and they will be moving each other. I am really confused and have no idea how to fix it so they move individually. In the event sheet look at all events under the "skeleton" group, not the "skeleton thrower" group as that is for another enemy.

    Also ignore the hand as I haven't done anything with it yet.

    Thanks in advance and if you need help understanding my event sheet then I will try my best to help you.

  • Just updated the file. Realised that I added the wrong one in first time round. You should see the enemies now. Error messages will appear when you run the game but this is only because I deleted Snow from the game. You can continue by telling (if Google chrome) to stop showing dialogue boxes.

  • The problem is your picking.

    There are no way for C2 to know which skeleton you are referring to, so it just select all skeletons that match your picking.

    And since you don't actually pick any in the event, but you use "Set skeleton Not Mirrored", it will just select all skeletons. The blue Keeperbox, is not really needed, you might as well just use the skeleton sprite it self. As you will now have twice as many units than needed.

    Anyway the problem is not easily solved, as "bad" picking is something that affect you whole game. Meaning that the structure for picking the correct skeletons are not there, so to fix your problem you have to redesign how these skeletons and Keeperboxes are linked together, so you can pick them correctly.

    So you need to really understand how picking works, otherwise you will keep running into weird problems. Would probably say that's the most important thing to understand in C2 when you start using it. Because if you get it wrong from the start when you create a game, there is a very big chance that you will have to spend a very long time solving problems with it later on.

    This is from a former post I wrote for someone with similar picking problems, maybe that will help you as well.

    Events:

    https://www.scirra.com/manual/75/how-events-work

    Objects:

    https://www.scirra.com/manual/68/objects

    System conditions:

    https://www.scirra.com/manual/124/system-conditions

    Basic picking:

    [quote:3eq87pq6]It sounds like you (not uncommon) get a bit confused about how picking works in C2.

    But the way you can look at picking of objects is like a sorting or reduction machine.

    Imagine you have 100 workers with the following attributes.

    100 Workers in total

    20 Workers are wearing a red shirt.

    40 Workers are wearing a blue shirt.

    30 Workers are wearing a yellow shirt.

    10 workers are not wearing a shirt.

    30 Workers are between 40 and 50 years old.

    50 Workers are between 20 and 30 years old,

    20 Workers are between 60 and 80 years old (No pension for these poor bastards!)

    Lets say you want all workers wearing blue shirts and that are above 60 year old to either go home or go to lunch.

    So what happens is:

    Pick all Workers : You pick all workers that match the condition that they are workers, in this case all are so its 100. (You don't really need this, its only for the explanation.)

    Workers must have blue shirts : This will reduce the number to 40 workers.

    Workers must be older than 60 : Depending on how many of those 40 workers matching this you will get a new number that further reduce or sort the amount of workers matching the former condition. Lets assume that its 15 workers.

    Now we cant reduce the amount anymore and we have found all the workers that match all our conditions. And since we want them to either go home or to lunch, and don't care how many goes where. We can do the following.

    For each Worker : This will go through each of the 15 remaining workers and tell each of them to either go home or to lunch.

    Go home or Go to Lunch

    So that's pretty much how it works whenever you pick objects, that you keep reducing or sorting them until those that remains fit whatever you want. And then if you want them to do different things you throw a "For each" at the end and then the options they have afterwards.

  • The problem is your picking.

    There are no way for C2 to know which skeleton you are referring to, so it just select all skeletons that match your picking.

    And since you don't actually pick any in the event, but you use "Set skeleton Not Mirrored", it will just select all skeletons. The blue Keeperbox, is not really needed, you might as well just use the skeleton sprite it self. As you will now have twice as many units than needed.

    Anyway the problem is not easily solved, as "bad" picking is something that affect you whole game. Meaning that the structure for picking the correct skeletons are not there, so to fix your problem you have to redesign how these skeletons and Keeperboxes are linked together, so you can pick them correctly.

    So you need to really understand how picking works, otherwise you will keep running into weird problems. Would probably say that's the most important thing to understand in C2 when you start using it. Because if you get it wrong from the start when you create a game, there is a very big chance that you will have to spend a very long time solving problems with it later on.

    This is from a former post I wrote for someone with similar picking problems, maybe that will help you as well.

    >

    >

    > Events:Objects:System conditions:Basic picking:

    > [quote:3exeb2kp]It sounds like you (not uncommon) get a bit confused about how picking works in C2.

    >

    > But the way you can look at picking of objects is like a sorting or reduction machine.

    >

    > Imagine you have 100 workers with the following attributes.

    >

    > 100 Workers in total

    >

    > 20 Workers are wearing a red shirt.

    > 40 Workers are wearing a blue shirt.

    > 30 Workers are wearing a yellow shirt.

    > 10 workers are not wearing a shirt.

    >

    > 30 Workers are between 40 and 50 years old.

    > 50 Workers are between 20 and 30 years old,

    > 20 Workers are between 60 and 80 years old (No pension for these poor bastards!)

    >

    > Lets say you want all workers wearing blue shirts and that are above 60 year old to either go home or go to lunch.

    >

    > So what happens is:

    > Pick all Workers : You pick all workers that match the condition that they are workers, in this case all are so its 100. (You don't really need this, its only for the explanation.)

    > Workers must have blue shirts : This will reduce the number to 40 workers.

    > Workers must be older than 60 : Depending on how many of those 40 workers matching this you will get a new number that further reduce or sort the amount of workers matching the former condition. Lets assume that its 15 workers.

    >

    > Now we cant reduce the amount anymore and we have found all the workers that match all our conditions. And since we want them to either go home or to lunch, and don't care how many goes where. We can do the following.

    >

    > For each Worker : This will go through each of the 15 remaining workers and tell each of them to either go home or to lunch.

    > Go home or Go to Lunch

    >

    > So that's pretty much how it works whenever you pick objects, that you keep reducing or sorting them until those that remains fit whatever you want. And then if you want them to do different things you throw a "For each" at the end and then the options they have afterwards.

    >

    Thank you for the reply.

    I will have a look through those links in your quoted post.

    With that screenshot image I copied that structure of a web page somewhere but didn't really understand what the person was doing. That was also part of the problem.

    Thanks for the information I will take a read through and hopefully change some of the events for more appropriate ones and be more specific with the skeletons.

  • Here is a very simple Capx that shows you how to use a family with a variable, and how you can use it to pick the correct workers in different ways.

    [attachment=0:2mc4mvk7][/attachment:2mc4mvk7]

  • Here is a very simple Capx that shows you how to use a family with a variable, and how you can use it to pick the correct workers in different ways.

    [attachment=0:16oe2kyj][/attachment:16oe2kyj]

    Thanks for the example in the capx file. It was helpful and gave me a better understanding of families and how to use them with a variable.

    Thank you for the help you have given to me in the past couple of posts, I think I have been pointed in the correct direction now

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Uh, sorry to butt in here, but. Your helpers in this thread missed a *really* obvious solution.

    Put your KeeperBox and SkeletonKeeper in a container together.

  • Uh, sorry to butt in here, but. Your helpers in this thread missed a *really* obvious solution.

    Put your KeeperBox and SkeletonKeeper in a container together.

    Yeah that a good idea Thumbs up

  • Uh, sorry to butt in here, but. Your helpers in this thread missed a *really* obvious solution.

    Put your KeeperBox and SkeletonKeeper in a container together.

    Hello,

    Sorry for late reply, I went to sleep.

    I had a go with making a container with the KeeperBox and SkeletonKeeper and it worked. They all now move around individually and don't interrupt each other.

    Even had a go with 3 SkeletonKeeper enemies and they do their own thing.

    Thanks for the reply.

  • > Uh, sorry to butt in here, but. Your helpers in this thread missed a *really* obvious solution.

    > Put your KeeperBox and SkeletonKeeper in a container together.

    >

    Yeah that a good idea Thumbs up

    I had a try with the container method and it worked.

    Thanks for your previous messages, they are helpful, the capx file you sent has given me an idea for the game or any other future projects I do.

    Good luck with any projects you do in the future.

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