Sprite Collision - Platformers

For questions about using Classic.

Post » Mon Jan 09, 2012 2:00 pm

I'm playing around with a platformer starring a wolf, and may have just realized why most platformers use two-legged characters.

If the player is standing on the edge of a ledge, then you have issues with overhanging feet, such as this image of Charlie from Deadeye's tutorials:



Presumably, this isn't too difficult to fix, since you could use specific animations to bring feet together, or leave one visibly dangling, when the player is close to a ledge's edge:





But I'm struggling to think of ways to address this issue with a four-legged animal. He's so long that the 'edge' detection would have to be pretty huge, and switching him to a balancing animation would probably lead to odd teleportations of the sprite - bringing him closer to the edge than he really is, just because his front legs are close enough. Having no balancing animations at all could easily lead to 90% of his length, and three of his four legs, seeming to stand on thin air, just because one of his paws is still on a platform...



Any suggestions?-Silver-2012-01-09 14:01:19
B
15
S
7
G
7
Posts: 250
Reputation: 5,298

Post » Mon Jan 09, 2012 2:06 pm

Hmmm..How about this?

-If far over the ledge: Automatically walk off or do some downwards hop.
-If barely over the ledge: Automatically walk backwards until all four legs are on the platform.Tokinsom2012-01-09 14:07:31
Image
B
225
S
27
G
13
Posts: 1,774
Reputation: 18,024

Post » Mon Jan 09, 2012 2:30 pm

I've been thinking about the downwards hop thing too. Trouble is it all depends on what frame the animation is at. So in the image above, if the wolf was right at the edge of a platform with his hind legs being the only part still touching it - that looks and works fine - so a downward hop wouldn't be necessary.

If, on the other hand, the animation frame was of his front legs landing at that stage, then he would look to be a good meter over the edge of the platform, and the downwards hop would be overdue.

Sticking that downwards hop requirement to the center of the sprite would be a trade-off of sorts, but could then easily lead to times when it looks slightly overdue (front legs slightly over the platform mid-run - with hind legs still in the air), or it could force the player to drop too early since his forlegs might be in the air and his hind legs a good half meter before the edge.

In a platformer, it seems pretty important to get these edge detections spot on. Being forced to drop down too early could be infuriating for players.-Silver-2012-01-09 14:31:37
B
15
S
7
G
7
Posts: 250
Reputation: 5,298

Post » Tue Jan 10, 2012 2:35 am

I don't see such a big problem.

If You did the jumping animation of the wolf close to its real jumping behaviour in life, the two front legs should be reaching forward, with the back legs spread to the back (in mid-air). And when he is landing, he should be landing with his two front legs first, and as they are touching the ground, the two back legs would come forward and probably touch the ground close to the front paws (slightly behind or in front of). Then the front legs make a slight step forward again, to ease out the body.

(Just google "wolf jumping" to see what I mean.)

So basically this should be able to look pretty natural, if You mimick its real moving behaviour.

Of course depending on which angle he is jumping from, say from below, or from above onto the surface, You'd have to change the angle of the animation a little.

For example, if I had the full animation, as I described above, I would generaly do it like this:

Let's assume the mid-air sprite is 100px wide. And the hotspot (for determining its position) is in the middle of the sprite. I roughly guess the size of the paws as 10px now, so the sprite needs to be on the surface with at least 10 px, to move onto it.

Assuming You're jumping from the left:

If Wolf is Jumping AND If Mid-AirAnimation is playing AND If Wolf.Left + 90(px) Equal or Greater than PlatformSprite.Left AND Wolf.Bottom Collides with PlatformSprite.Top -> Play LandingAnimation; Move Wolf.X with about 90px. (because body is easing out in animation and taking a step forward for landing)

Of course You would have to slightly adjust it for different jumping angles, like I mentioned before. Shindoh2012-01-10 02:42:35
B
3
G
1
Posts: 70
Reputation: 615

Post » Tue Jan 10, 2012 4:29 am

most games don't have that type of accuracy when lining up animations going from one animation to another. most 2d games instantly begin the jumping/slipping/tooCloseToEdge animation regardless of the point in the running animation they are in.

One exception is Prince of Persia, which ends up having a very different feel. A wolf should feel free, not stuck to a grid like prince of persia, and no player will be able to predict where in their wolves run they'll be when they reach an edge, and games are more fun when you can control them.   

That being said, I do think it's worth it to take the time to make animations blend smoothly into eachother, if that's something you decide you want to do. but I think the animation should work around the gameplay, not the other way around. for example, it would be better to have an alternate stopping-near-the-edge animation that starts from a different foot, rather than the same jump or near fall on the edge would have a different outcome depending on the positions of the legs in the animation.

Most of my personal projects in the past year or so have been experiments dealing with animation blending(albeit using bones, and specialized plugins), so it's an area of particular interest to me.   

Also, I like the wolf sprite you have there. is that your own art? if so, would you mind linking an animated gif, or your da page?lucid2012-01-10 04:34:07
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Tue Jan 10, 2012 5:04 am

Could you not make the legs go together, in a sort of squat? Here's sort of what I mean:



Alternatively you could do something like this:

Image Image
Scirra Founder
B
124
S
37
G
25
Posts: 3,945
Reputation: 44,897

Post » Tue Jan 10, 2012 5:51 am

[QUOTE=Tom] [/QUOTE]
Oh my gosh, Garfield lives!
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Tue Jan 10, 2012 6:19 pm

Not sure how to use a multi-quote feature on this forum...

@Shindoh - You're right in everything you say. It's probably something I'll need to play around with. I just panicked when I started working on the running animation, wondering if I'm going to run in issues with this.

But yes, a wolf's paws all land in roughly the same spot. The issue I'll have is that the sprite's hotspot isn't going to be matched up to the wolf's... center of gravity? IE: When he's jumping up, his paws and attachment to the platform are at his rear, like in my original sprite above. But when he lands, his paws are at his front (image below). The hotspot, and the only thing the engine really cares about, will always be at the center of the sprite though. The player will be judging by the wolf's feet.

But as you say, it may well be something I can find the right balance for. And I plan on creating a lot of animations to make it look and feel right. So long as it CAN be done, I'll try my best to do it :)



@Lucid - It is my own artwork, thanks for the compliment :) And yes, I plan on creating a lot of animations for this, and agree that a different stopping animation depending on the current animation frame would be important. I don't see any issues with getting that to work. I also want a climbing animation, for when the wolf is only just hitting the right height to climb up to a higher platform, which I have plenty of ideas for creating. The only part that scares me is the jumping animation. Naturally a wolf jumps from his hind legs of course, so I'm not sure how to handle a jump command being issued when the wolf is on his front legs, or mid-air in his run cycle. Jumping back to a hind leg frame could look jarring...

But that's something I'll tackle at a later date. For now I'm working on the run animation. I plan on completing 8 main frames, and editing them in Anime Studio to blend them together nicely. I don't have much experience in that program yet aside from animating trees, but if it's a subject you enjoy then I'd love some feedback from you when I've completed my first pass at the wolf's run cycle.

So far, I've done 6 of the 8 main frames, and should be done by the weekend. I'll post an animated image then :)


@Tom - That's something I have in mind, yes, but I'm worried about... teleportation, for lack of a better word. It's such a long sprite when he's standing that on small platforms he'll pretty much always have one of his paws close to a ledge. I'd have to find a way to balance it, but I can imagine it looking strange if the wolf is triggered as being close enough to the left edge to pull him back to a squatting animation on the left ledge, and after half a meter of walking forwards he's triggered as having his front paws close enough to pull him forward into a squatting animation on the right ledge.

I guess the easy way out is to only have long platforms =P
B
15
S
7
G
7
Posts: 250
Reputation: 5,298


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests