How do I make different enemies from one abstract class.

0 favourites
  • 4 posts
From the Asset Store
Adjusting the game screen for different resolutions (Letterbox scale)
  • Hello!

    In my platformer game, I wish to have enemies of three or four types.

    They have very much in common, but have some differencies, for instance

    • different HP,
    • different view distance
    • different speed
    • etc...

    I have written the logic for one enemy of type A, if I clone the object, I have to copy all the logic of it for type B, as well as all logic of other interactions...

    I suppose there should be a way to make "abstract" enemy, and somehow shift it a little. Is there any?

    What are best practicies of making enemy variations?

    Thank you

  • Assuming your different values are instance variables, you can create a function to spawn enemy with a parameter "enemy type". In the function, seperate out if enemy type=a then set certain variables, if enemy type=b then set variables, ect.

    Create your behaviors based on each enemy's instance variables.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you! I'll try.

    Is it better to place enemies directly, on layout from the palette or to make them by Create Object action at the start of layout?

  • That's up to your own style or workflow. If you need to randomize your enemies or generate then dynamically, I would create them via events.

    Or if you like/need to place them in the layout editor for level design purposes, then just set the variables manually then copy and paste.

    You can also just set a single instance variable "monster type" when placing on the layout editor, and adjust all the other variables based on that by event on start of layout similar to how i described with a function. This will make it easier to make changes and adjustments later.

    Really is up to your own preference and what is most suitable for your game.

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