Animating with Families

Get help using Construct 2

Post » Wed Jun 12, 2013 4:09 pm

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.
B
5
S
2
Posts: 37
Reputation: 699

Post » Wed Jun 12, 2013 4:17 pm

[QUOTE=noisetank]
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.[/QUOTE]

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.
B
24
S
9
G
7
Posts: 756
Reputation: 7,312

Post » Thu Jun 13, 2013 2:38 am

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"
B
5
S
2
Posts: 37
Reputation: 699

Post » Thu Jun 13, 2013 5:43 am

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.
B
24
S
9
G
7
Posts: 756
Reputation: 7,312

Post » Thu Jun 13, 2013 6:10 am

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.
B
47
S
14
G
7
Posts: 603
Reputation: 8,151

Post » Thu Jun 13, 2013 6:52 am

[QUOTE=EncryptedCow] 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.[/QUOTE]

They would not be picked if you pick the family the object is in.vee412013-06-13 06:53:09
B
24
S
9
G
7
Posts: 756
Reputation: 7,312

Post » Thu Jun 13, 2013 7:05 am

@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.EncryptedCow2013-06-13 07:06:31
B
47
S
14
G
7
Posts: 603
Reputation: 8,151

Post » Thu Jun 13, 2013 8:58 am

[QUOTE=EncryptedCow] 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.[/QUOTE]

@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.
B
24
S
9
G
7
Posts: 756
Reputation: 7,312

Post » Fri Jun 14, 2013 3:02 am

[QUOTE=vee41] 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.[/QUOTE]

Just what I was looking for, thanks. :D
B
5
S
2
Posts: 37
Reputation: 699

Post » Fri Jun 14, 2013 8:06 pm

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
B
35
S
5
Posts: 411
Reputation: 3,406

Next

Return to How do I....?

Who is online

Users browsing this forum: dop2000, RIDETHEPIG and 4 guests