How do I make different enemies from one abstract class.

Get help using Construct 2

Post » Thu Sep 01, 2016 9:22 pm

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
B
3
Posts: 7
Reputation: 189

Post » Thu Sep 01, 2016 9:33 pm

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.
Mistakes were made.
B
49
S
24
G
107
Posts: 1,579
Reputation: 60,299

Post » Thu Sep 01, 2016 9:47 pm

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?
B
3
Posts: 7
Reputation: 189

Post » Thu Sep 01, 2016 10:01 pm

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.
Mistakes were made.
B
49
S
24
G
107
Posts: 1,579
Reputation: 60,299


Return to How do I....?

Who is online

Users browsing this forum: georeb, InfiniteRockets, Zav and 7 guests