Have each enemy act Independently

0 favourites
  • 5 posts
From the Asset Store
Give Sound to the enemies that are part of your game! :)
  • So, I'm making a game for school, and I can't get the enemies to work right. I'm probably doing something wrong with Instance Variables, but I want each enemy to use its actions dependent on itself, rather than the first one spawned. Any help would be greatly appreciated!

  • This might be helpful.

    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:dphqktb8]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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hmm... I tried implementing some of this stuff, but still to no avail...

  • I have looked through your code and that's the reason I posted those links, as from what I can see these are the areas that you need and are stuck with. But also I wouldn't know where to begin, it would require a huge restructuring of the code, that would simply take to long time to explain and probably wouldn't make much sense to you, if you are not somewhat into what those links are about and how to use them.

    A good advise when you post for help with a Capx is to make sure there are comments and groups, its not easy for someone that looks at it the first time to troubleshoot it, and think most will not even bother to try, simply because It takes to long time. And ofc be specific about the problem, you haven't said what you want them to do, and looking in your code, it seems that they can only attack the player? Which makes it even harder to know what exactly you are looking for help with.

    If you are not sure about how to pick object, use loops etc. Make a simple app with 3 instances of an object, which can just jump to a random position on the screen or something like that and then just try to find a way so you can pick the correct instance or make all of them do it using a loop. And then try to copy it to your game.

  • Okay. Thanks for your help!

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