Working With Family Objects Within Construct 3

Jun
30

Working With Family Objects Within Construct 3

As you learn how to work with, and create many different types of projects within the Construct 3 Game Engine. You will find certain features of the application in particular, that will make your prototyping & development cycles much faster, and easier to boot! One of these features is the “Family Object”. To put this basically it is a built in plugin/object type, which allows you to group multiple objects into the same “Family”. Where all objects within that Family Object share the same behaviors, instance variables, code blocks within event sheets, etc.

As long as every object is of the same plugin type, and carry the same instance variables, and behaviors, they can be grouped into one of these Family Objects. Think of them as a group, room, or block of Objects that can hold multiple Sprite Objects. Or perhaps another type of Object, which all will be acting in the same way. This is mostly used for the grouping of Sprite Objects, which will need to perform the same actions when certain conditions are met. Play the same animations, have the same alterations made to their variables at specific times, perform the same actions, etc. For example grouping together playable characters, enemies, bullet styles, particle effects, etc.

But, each object within the family will interact through it’s events/actions separately from the other objects within that family. So for example, say if you jump on one platform enemy, that specific enemy that was jumped onto will be selected to play its taking damage animation, and then take the proper damage off its Health variable. It will not happen to every Object within the Family, at the same time as the collision with that singled out platform enemy. This is the way Construct 3 uses its Selected Objects List(SoL), through the Event Block system. Construct 3’s “SoL” is for another article, all together :).

In this brief example. I am going to talk about how I took two enemies created the very beginning of this week, and on the following day created several more enemies of each type. One of the enemies is a Mushroom, that has basic platform behaviors, along with flashing, fading, and other behaviors to trigger when certain conditions are met. The other enemy is a flying Yellowjacket, which patrols certain areas within a level using sine behaviors. Then uses its Line of Sight and Bullet behaviors to give chase to the Player once within a certain range of the player. If the player loses the flying Yellowjacket by moving outside it’s Line of Sight, the Yellowjacket will return to its original patrolling area, and continue its lookout for the Player in all directions. Both enemy types can be hit with projectiles(an apple in this case) to cause damage, and the Mushroom enemy can be jumped/bounced on to cause damage to it as well.

In any case. The day after creating each of these enemies. I decided to create several more enemies within the two styles(platform enmies, and flying enemies). So I created multiple platform enemies(snails, slimes, etc), with the same animation names as the original Mushroom. Then I did the same thing for the flying enemies, creating multiple flying bats to use similar behaviors as the Yellowjacket. These too are required to have the same animations/instance variables as the original Yellowjacket.

The next step was to create two Family Objects, to group each enemy type into. One called “PlatformEnemies”, and another “FlyingEnemies”. Then, it was a simple matter of taking the behaviors, and instance variables from the Mushroom enemy, and adding them across the entire “PlatformEnemies” family group. If this sounds difficult, it is not. It is the exact same method to add behaviors and instance variables to a single object. Except in this case you add them to a family instead, and it takes the same amount of clicks, typing, etc, to get the task done. Whether you are applying these behaviors and/or variables to a single object, or a family object. Then I simply did the same thing for the “FyingEnemies” family group, using the same exact behaviors and instance variables from the Yellowjacket, and creating them directly on that group of Flying Enemies.

After that, all I needed to do was move into the Event Sheet for both of the enemy types. Then swap out every Event Condition & corresponding Action to be taken for each enemy type, and replace it with the enemy type’s Family Object. Locating every area calling for the Mushroom object, and then replacing the Mushroom with the “PlatformEnemies” family object. And, then doing the same for the Flying Enemies. Finding every instance or location within the Event Sheet that called for the Yellowjacket object, and then replacing the Yellowjacket with the “FlyingEnemies” family object.

This can be done easily by searching the Event Sheet, by using “CTRL + F” and typing in either “Mushroom” or “YellowJacket”. This will bring up a list that can be brought into a separate window, which contains each line that has that corresponding Object is used on. Then double clicking on each line will bring you directly to that line in the Event Sheet for that search result. Once there, simply right-clicking the line, choosing “Replace Object”, and replace the enemy for its new Family Object. Like I said earlier. As long as the newly created Family Object contains the same exact Object Behaviors, and Instance Variables, it should easily replace the single object for the family object 🙂

This can be used to turn what would be hundreds of Event Condition & Action blocks, and into 20 or so. Rather than redoing the same blocks over and over again for each enemy. You can simply create Events and Actions that apply to the entire family of enemies. In a few hours or so, I was able to add seven new enemies to Teddy’s Adventures. Then change the Event Sheet over to use their Family Objects rather than just a sole Sprite Object for either the Mushroom, or Yellowjacket enemies. This would take a lot of work in some other game engines, but Construct 3 makes this super simple to accomplish. You can also isolate specific objects within a family, through various methods. If you need particular objects within a family of objects to act and react in different ways than others when the same conditions are met.

I hope most of that rambling mumbo jumbo made sense. XD If not, do not worry about it. I will be covering all of this within the Educational Tutorial Series where you can recreate Teddy’s Adventures alongside me. Watching over my shoulder as it were, using video recordings, capturing my every move and change within the project, as it grows and becomes more and more advanced.

I’ve included a short game play clip and screenshots below. To show the new enemies that were implemented. As you can see they all respond in the same way, and make the same actions, but are each using their own Sprite Object. As of the video, I did not have the flying enemies polished like they are right now, with their patrolling, and player chasing mechanics. So in the video below, they simply will patrol their starting area using two sine behaviors with different properties on each. Then face the player depending on where the player is located in relation to each enemy on the X Axis.

Example Video of Multiple Enemies using Family Objects within Construct 3
PlatformEnemies Family Object Screenshot
FlyingEnemies Family Object Screenshot
Avatar photo

About Colin

BrainwaveCreations Indie Game Studio

My Indie Game Studio's website is located at

BrainwaveCreations.com

Recent Posts