[Solved] New to using Families. Having trouble changing their individual states.

0 favourites
  • 2 posts
From the Asset Store
State Machine
$9.90 USD
10% off
State Machine is a great tool for managing the state of anything in your game.
  • Hey all.

    I've been rebuilding a game I made for the Ludum Dare challenge a few weeks back. I've been optimizing, and as such have begun using Families for my Enemies. So I don't need to make the same blocks in the Event Sheet for each enemy type as I was before.

    I got their movement to work just fine, but setting up proper collision to turn each one around, when it collides with an object setup on every platform at the start of the layout.

    I'm moving onto the combat system, and I'm having some trouble changing the Enemies' State over to "Attack", which should play an animation with the same exact name. I'm not sure what I'm doing wrong. So before I get to far, I figured I would come here and ask for help.

    I do apologize if this has already been answered, I've been searching the forums here, and Google for a while. I also read the documentation on the Families Object. Also, checked out the Families example in Construct. Not sure what I am doing wrong in this case.

    As you can see in the "Enemy Setup", I am creating some debug text above each enemy to see if the State changes over to Attack. And, so far no good. Under the "Platform Enemy Attacks > Melee Attack" Group, you can see my attempt at switching the enemies state to Attack, when it is in line of sight. While also making sure it faces the Player by checking the PlayerBox's X coordinate.

    So far the mirroring of each enemy is working properly, based on if it is within LoS of the player or not. But, it never changes over to the "Attack" state. As you can see I tried it in the sub events. Then tested setting it to Attack right next to the condition for "Has LineOfSight". Then setup a whole new conditional block, to check if in Attack State to set the animation manually.

    EDIT: I meant to mention, that it seems like the enemy gets ready to attack. It shows the first frame of their Attack Animation, and mirror appropriately to face the Player, but do not stop and play the animation. They were doing just that, when I had them each setup individually, and not within a Family Object.

    The screenshot of my Event Sheet is large, so I've linked to it here: https://i.ibb.co/dDWLwxk/screencapture-editor-construct-net-r292-2022-04-27-22-26-44.png

    If anyone notices what I'm doing wrong here, and has some time to lend some help. I'd greatly appreciate it :) I have a feeling I need to do a similar "For Each" Condition, like I did for creating the debug text object "txt_EnemiesState" over each enemy in the family. I'm assuming I would need a similar check to see which Enemy to change to the Attack State? I remember reading or watching something a while back. Something about generating UIDs using a For Each on a Family, then taking proper action based on the UID. Not sure if that's required in this instance. I'm a complete newb when it comes to the Family Structure within Construct.

    Or maybe it is something entirely different, staring me right in the face.

    I hope everyone is having a fantastic day/night!

    Thanks in advance! Take care :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Wow.... I must be tired. All I was missing was another condition in the bottom Event in the Melee Attack Group. The one making sure that the PlatformEnemiesState is not equal to "Taking Damage". I just needed to add the PlatformEnemiesState is not equal to "Attack" as well... I just came back here, to study the screenshot I uploaded. And, spotted the error... It was constantly setting the state to Walking, and the Attack state didn't have any chance to become active.

    Carry on! Maybe someone will learn from this. As always, if anyone has any advice on how to better do certain things on the Event Sheet here. Feel free to share some pointers :). I always enjoy some advice. As much as I enjoy providing it.

    While I'm at it. Here is my entire Event Sheet so far: https://i.ibb.co/SybSLr9/Event-Sheet.png . Feel free to snoop around.

    Peace, and Good Night

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