Enemies: In single object or multiple objects in a family?

0 favourites
  • 4 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • Hello! I have a short question that came to my mind and I wanted to know your opinion.

    I am starting to make enemies for my game. I'm building different types of enemies, however, they all have some things in common, like physics.

    I was considering making one single object called "enemy" with all the necessary behaviors which automatically go on or off depending on the enemy (set in the form of animation). However, I was thinking to make this choice purely to make things "faster" or easier for the game to process.

    Do you think I should make one enemy for each object, and maybe group them as a family?

    Thank you!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If each enemy type has one animation and they are not too big, then you can probably use one sprite for all enemies.

    If there are multiple animations per enemy (for example, idle, walk, attack), they may be difficult to manage when they are in one sprite. Then make different objects and combine them into a family.

    Another thing to consider is memory usage. A single sprite with many heavy animations can use a lot of memory. So if your game has different enemy types on different levels, I would definitely suggest keeping them in separate sprites to save on memory.

  • If each enemy type has one animation and they are not too big, then you can probably use one sprite for all enemies.

    If there are multiple animations per enemy (for example, idle, walk, attack), they may be difficult to manage when they are in one sprite. Then make different objects and combine them into a family.

    Another thing to consider is memory usage. A single sprite with many heavy animations can use a lot of memory. So if your game has different enemy types on different levels, I would definitely suggest keeping them in separate sprites to save on memory.

    Hi! Thank you for your answer, as always you're quick and respectful.

    The enemies I'm making won't use many sprites, and they are somewhat small.

    But I'm planning to create a different type of enemies. I'm not planning to add many enemies in one level, however.

    Most of the enemies won't use heavy animations. The "Idle" can be just one single frame, and the "attack" the rest of the frames (which usually are max 5).

  • Ultimately only you can decide which option will be better for your game, and you may regret your decision later :)

    A single sprite may be easier to deal with. You'll have to store enemy type in an instance variable. Then, for example, if you need to set an idle animation use Enemy.type&"_idle". To check if an idle animation is playing for any enemy, you will have to do something like this:

    System Pick Enemy by evaluate right(Enemy.AnimationName,5)="_idle"
    

    If you start with a single sprite, but later change your mind and decide to split enemies into multiple sprites, here is a tutorial on how to upgrade them to a family:

    construct.net/en/tutorials/upgrade-object-family-319

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