0 Favourites

How do I Control Several Monster Properties

  • Hey there,

    So basically, I have one monster who, when hit, pops up the damage received, over its head. It has the normal instance variables that an enemy normally would and its own movement etc. This all works great for now...

    My problem is that I want to add different types of monsters into the game and somehow group the collision events with my weapon. Unfortunately, when I use a Family, the game doesn't work as intended. Now, I can manually insert each onWeaponHit for every single monster and this will work how I want it to... but I feel this probably isn't the correct way.

    Here is what I am currently using. Should I just repeat this for each monster type or do you know of a way to handle all of this with something simpler?

  • Create a Family for your monsters. Do this by selecting 'Families' in the Project bar, right-clicking, and selecting 'Add family...'. A dialog will pop up where you can select your monster, and add it to the list. Now, when you clone the monster, it will create a new monster in the same family. You can apply rules to the whole family, or just single monsters, so they can all - for example - be damaged the same way, but move differently.

    You should be able to replace your monster in the current project with a Family in order to create a basic 'class' of monster from its current behaviours by simply using 'Replace object' on these events, and replacing the monster with its family. You may need to create new variables for universal properties like health etc on the family, as instance variables from inidividual monsters will not be visible when referring to their family.

    See

  • Thank you for the reply but unfortunately Families will not work for what I am trying to do here. I guess I will just have to duplicate the events for each enemy type.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Can you describe how Families aren't working the way you're expecting them to? Because this is the exact use-case for Families - if they're not working how you expect, there's a good chance you're somehow mis-using them.

  • that's the least you can do for now. duplicate the events and action for each monster/enemy type

  • Maybe your problem and the one I was having are related? See here..

  • As seen in the first response, yes you use families, this avoids the need to duplicate events for each enemy type, that's what families are for!

  • Indeed families sounds like something that should work.

    Your issue might come from Function picking that you would have to handle differently.

    You rely on the Function.ReturnValue from "Monster_Hit", but pass no UID for picking to MonsterHit (and we don't know what is inside this function).

    Adapt it so it can handle families and is passed the family UID of the correctly picked monster and all should work as intended.

  • Can you describe how Families aren't working the way you're expecting them to? Because this is the exact use-case for Families - if they're not working how you expect, there's a good chance you're somehow mis-using them.

    Agree. Families is the way to go.

    Some tips:

    1. the "for each" event you have at event 28 is not necessary because C2 already does a for each object when you have it on a condition like "is overlapping Monster1" in your case. Read: "Unnecessary 'For-each' loops" in

    2. Usually when you use "every X seconds", es because you want to do something "every x seconds", then, other conditions have to be after that condition not before like the one you have at event 28. Always put conditions In words so it would make sense like "every x seconds I want to check if some object is overlapping another". In your code, collision check is being made every tick, not every x seconds.

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