Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411529 Posts in 69377 Topics- by 58433 Members - Latest Member: Bohdan_Zoshchenko

April 29, 2024, 01:46:17 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperArt (Moderator: JWK5)Taking the collision shape into account
Pages: [1]
Print
Author Topic: Taking the collision shape into account  (Read 1941 times)
VideroBoy
Level 0
**



View Profile WWW
« on: November 14, 2010, 08:21:08 PM »

This question is about drawing sprites, but it's from the perspective of how the sprite will be used by the game engine and how it's perceived by the player, so I believe it's more technical than the other art threads I've seen.

I am working on a 2D action RPG.*  My actors are represented by circles for collision, where the circles are of the same diameter as my tiles.  In order to depict perspective the actors are also being designed to be taller than this diameter/tile-size to allow a set amount of overlap.  I am constraining this overlap size to prevent tiles and actors from being obscured completely.



To give specific numbers, my tiles are 64x64 pixels.  The actor collision circles are likewise 64 pixels wide.  The actor sprite itself is designed to be 64x96, so that it will overlap things by 32 pixels (half a tile).  In designing an actor sprite I've avoided drawing beyond the bottom half of the collision circle.  Also note that I've left room at the top for hair.

My issue is that, after looking at my finished sprite template, I can't help but notice the extra empty space inside the actor's collision circle.



I'm wondering what would happen if I used this circle for attack hit detection given the amount of empty space, especially when the actor is facing left or right (as depicted).  I can stretch the actor height-wise to use up more vertical space, but I'm not sure how to use up the sides without giving my guy obesity.

* The game won't actually have RPG elements, so it's really an action adventure. But "action adventure" is a broad term and I'm trying to avoid calling it a Zelda-like. Or has "Zelda-like" become a common term?

The sprite itself is decent, right?
Logged
Fallsburg
Level 10
*****


Fear the CircleCat


View Profile
« Reply #1 on: November 15, 2010, 11:45:05 AM »

Well, I feel like a rectangle is a far more accurate shape for you than a circle would be, but if you want to use circles I would use multiple to determine collisions. 
In fact for the Zelda style you typically want a circle that corresponds to the shadow, or in other terms their footprint on the ground, which you use to determine their collision with the environment.  You want your characters to stop when their feet hit a boulder, not their head. 
What you have currently would be extremely annoying for players.  They are going to find it really annoying when they get "hit" and it is nowhere near their sprite.  In my experience you want to go bigger or smaller depending on which is better for the player.  I.e. the shape that determines collision with enemies and enemy projectiles is slightly smaller than their sprite.  The shape that determines whether they are on the edge of a cliff or falling off is slightly bigger than their sprite.

Personally, I use Zelda-like to describe my game.  For some types of games that would be stupid, but I feel Zelda-like is far more useful than action-adventure in describing the gameplay.
Logged
VideroBoy
Level 0
**



View Profile WWW
« Reply #2 on: November 15, 2010, 01:04:14 PM »

I'm using circles for collision handling to make sliding around corners and along walls easier, especially since I'm using Box2D. My attempt to write my own collision detection was...painful for some reason.

I tried to see what the collision shape would look like if it were closer to the actor's shadow.

My biggest issue with this is that the amount of overlap this sprite is capable of has greatly increased, past the 32 pixel limit I tried to impose. There's also the fact that there's still regions of empty space in the circle for some frames, like the front-facing idle frame and the side-facing frames (the circle doesn't move between frames). The circle is still correct in terms of the perspective of the sprite, which we can think of being inside an orthographic cylinder, but it'll still be annoying for hit detection.

I'm wondering if I should give my actors two collision shapes, one for movement collision and the other for hit detection. The movement shape would be a circle around the feet, while the hit shape could be a rectangle that tightly covers the sprite. I'm not sure how I'd work actor-actor movement collision (non-attacking) in this scheme though. I want actors to be able to slide around each other much like they can slide around the terrain, so I may use the same collision shape I use for terrain collision. I wouldn't want the movement shape to be too big such that actors can't get close enough to each other to reach their hit collision shapes. I wouldn't want the movement shape to be too small either or actors may be able to overlap each other too much.
Logged
Jetrel
Level 0
***



View Profile
« Reply #3 on: November 19, 2010, 06:24:44 PM »

I'm wondering if I should give my actors two collision shapes, one for movement collision and the other for hit detection. The movement shape would be a circle around the feet, while the hit shape could be a rectangle that tightly covers the sprite. I'm not sure how I'd work actor-actor movement collision (non-attacking) in this scheme though. I want actors to be able to slide around each other much like they can slide around the terrain, so I may use the same collision shape I use for terrain collision. I wouldn't want the movement shape to be too big such that actors can't get close enough to each other to reach their hit collision shapes. I wouldn't want the movement shape to be too small either or actors may be able to overlap each other too much.

Frogatto did this;  we use a rectangle for terrain collisions, and then use multiple, named rectangles to delineate area different characters can interact through.  For the named rectangles, we also make these based on transparent/opaque pixels, so e.g. your attack only collides when it's graphics literally *touch* the opponent.

By having named rectangles, we can specify different areas for different effects;  frogatto's tongue is not part of his vulnerable body area, so firing it at an opponent's spikes/teeth lets you grab them without hurting yourself - and only his tongue can snag an opponent.
Logged
VideroBoy
Level 0
**



View Profile WWW
« Reply #4 on: November 19, 2010, 07:29:23 PM »

That makes sense.  I can keep my giant circle for terrain collision and use other shapes (likely rectangles) for damage hit detection.

Still, how do you suppose I should handle actor-actor (no-damage) collision?  I'd like to keep it based on circles to make actors sliding around each other easier.  I'd like to size the circle such that I get some overlap between actors but not too much overlap.  But I don't want a situation where an actor can't attack another actor because their movement collision circles spaces them such that one can't reach the other's damage rectangle with its attack.

For the named rectangles, we also make these based on transparent/opaque pixels, so e.g. your attack only collides when it's graphics literally *touch* the opponent.
How "per-pixel" is this?  You don't try to cover every pixel that can be involved in the relevant collision, right?
Logged
Jetrel
Level 0
***



View Profile
« Reply #5 on: November 19, 2010, 08:25:11 PM »

That makes sense.  I can keep my giant circle for terrain collision and use other shapes (likely rectangles) for damage hit detection.

Still, how do you suppose I should handle actor-actor (no-damage) collision?  I'd like to keep it based on circles to make actors sliding around each other easier.  I'd like to size the circle such that I get some overlap between actors but not too much overlap.  But I don't want a situation where an actor can't attack another actor because their movement collision circles spaces them such that one can't reach the other's damage rectangle with its attack.

If that's an issue, make smaller circles.  You don't want to get too technically complicated, especially for a simpler game like this.

I mean, realistically, your current circle size should never run into "one can't reach the other's damage rectangle with their attack".  All attacks in a fighting game with tiny sprites like this should pretty much reach at least 3/4 of a body diameter outwards.  If your attacks don't reach that far, you're doing it wrong in terms of poses/anatomy.  If this guy throws any punch, kick, or grab, or swings a weapon, it'll reach that far.  Please don't give me any gruff about how real martial-artists keep their back straight or yada-yada; I know what I'm talking about, and I've animated hundreds [lit.] of weapon-swings for a videogame.  You don't need to go all looney-tunes on stuff, but your motions do need to "project" and be visible.

As for actor-actor collision; what we did in frogatto was that all characters' solidity was such that no two things can occupy the same space.  They have a rectangle, and these rectangles both can't cross the terrain, and can't cross each other.


We made two additional nuances - nothing can cross terrain, but for characters and such, we came up with an idea of "solid dimensions", so that players can pass through NPCs;  objects only collide with other objects in their same dimension (although objects can be in multiple dimensions).  Also, to make slopes work nicely, our objects actually aren't done with rectangles, they're done with sort of an inverted "house" shape, with the bottom corners cut off;  thus they'll fit perfectly on a 45° slope.  Naturally, this means we can't do >45° slopes, but those would be a tad awkward anyways, and we can get most of their aesthetic effect with a staggered mix of vertical and 45° wall sections.
Logged
VideroBoy
Level 0
**



View Profile WWW
« Reply #6 on: November 21, 2010, 01:56:21 PM »

So, to make sure an attack can reach past an actor's movement collision circle to its damage collision shape, I should just make the attack long enough.

I guess I can work with that. Who, Me?
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic