Animating with Families

0 favourites
  • 11 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • So, I'm still fairly new to Construct and even more new to the paid version, so I'm having a bit of difficulty figuring out how to properly implement the Families feature.

    First, some background:

    The main character of my game has an invisible sprite with platformer behavior and a visible sprite with all the animations (walking, running, jumping, shooting, etc) set to the player's position every tick. To trigger these animations, I use the player object's platformer events to change the player_sprite object's animation (ex. If player is on ground and player is moving, set player_sprite animation to run).

    NPCs (be they enemies or friendlies) will generally follow the same set of rules. They may not have quite the same range as the player, but they'll still have the basics (walk, run, jump, shoot, etc) that will trigger much in the same way (if object does platformer event, then visible sptrite does animation).

    What I'd like to do:

    Setting up individual events for every character would be a pain. So instead, I'd like to use families to simplify things and make it SUPER easy to add new characters on the fly. I've been careful to use the same naming conventions across character animations ("Walk", "Run", etc) so there's no issue there, but the think I'm REALLY struggling with is how to select which animation sprite belongs to the picked object sprite.

    As I said, the object that actually MOVES is SEPARATE from the object that the player sees animating. They have no actual connection to each other as far as the game is concerned, aside from the "set sprite to object every tick" event (which still doesn't mean anything to Construct).

    What can I do to make it so this works?

    To summarize the intended functionality with an example event:

    If Character family is jumping, set picked object's animation sprite (which I have put in an Animation family) to "Jump". Making this event will currently just make EVERY character sprite play the "Jump" animation, rather than find just the one that belongs to the acting character.

  • To summarize the intended functionality with an example event:

    If Character family is jumping, set picked object's animation sprite (which I have put in an Animation family) to "Jump". Making this event will currently just make EVERY character sprite play the "Jump" animation, rather than find just the one that belongs to the acting character.

    My instincts would say this should work:

    On Character jumping

    .. Character: set animation to "Jump"

    If all characters are set to Jump animation I think there is a problem with picking.

  • The issue is that it's not the character object itself that's animating, it's the character sprite object that goes along with it. As suggested in all the tutorials I've read, the character object that does all the platforming movements is invisible with a set hitbox. The animations for this character object are in a separate object.

    So my objects are as follows:

    player

    player_sprite

    enemy

    enemy_sprite

    My families:

    Characters

    • player
    • enemy

    Characters_Sprites

    • player_sprite
    • enemy_sprite

    And my events would set up something like this (this doesn't work and I understand why, I just don't know how to fix it):

    Every tick > Set position of player_sprite to player

    Every tick > Set position of enemy_sprite to enemy

    If "Characters" is Jumping > Set "Characters_Sprite" animation to "Jump"

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That would be a picking problem. :)

    What you'll need to do is pick the "Character_Sprite" that is related to the "Character". Few of the approaches you could take:

    • Saving UID of the "Character_Sprite" to instance variable of "Character" and using "Pick by UID" action.
    • Picking the "Character_Sprite" nearest to "Character". Might be risky approach, depending on how your game works.
  • Or put the enemy_sprite in a container of enemy. That way it will always know which enemy_sprite to reference. I could be wrong though, I don't use containers too often.

  • Or put the enemy_sprite in a container of enemy. That way it will always know which enemy_sprite to reference. I could be wrong though, I don't use containers too often.

    They would not be picked if you pick the family the object is in.

  • vee41 but if you're using containers there would be no need for the family. just check the enemy and tell enemy_sprite what animation to play.

    Edit: There would be no need for the family for the animation stuff, you would still need it for other stuff like attacking them.

  • vee41 but if you're using containers there would be no need for the family. just check the enemy and tell enemy_sprite what animation to play.

    Edit: There would be no need for the family for the animation stuff, you would still need it for other stuff like attacking them.

    EncryptedCow But as he is doing it with families, there is need to use a family here. Player and enemy sprites are separate objects in a family, but would need to use the same animation triggers.

  • That would be a picking problem. :)

    What you'll need to do is pick the "Character_Sprite" that is related to the "Character". Few of the approaches you could take:

    - Saving UID of the "Character_Sprite" to instance variable of "Character" and using "Pick by UID" action.

    - Picking the "Character_Sprite" nearest to "Character". Might be risky approach, depending on how your game works.

    Just what I was looking for, thanks. :D

  • Did this help you noisetank? I'm going to be moving enemy collisions and projectiles into families, and this is going to be huge for me, but will take time. I'll need to make it so if a family projectile hits an enemy in the enemy family, react/animate appropriately

  • Did this help you noisetank? I'm going to be moving enemy collisions and projectiles into families, and this is going to be huge for me, but will take time. I'll need to make it so if a family projectile hits an enemy in the enemy family, react/animate appropriately

    It's worked to an extent...I can make my player character animate and move independent of the enemy, however I've noticed that the enemy seems to somehow grab the "orientation" variable I set up (sprite is mirrored or not mirrored depending on left or right orientation) and will turn in the same direction as my character does. Weird.

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