Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


What type of colliders and rigidbody set-up to use for animated character in Unity


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 lougv22   Members   -  Reputation: 226

Like
0Likes
Like

Posted 22 March 2014 - 08:04 PM

So I am wondering, what type of colliders would be best for a 3D animated character in a 2D fighting game, otherwise known as 2.5D (something like Street Fighter IV), in Unity? I am assuming a rigidbody would be needed since there will be a lot of physics involved and responses to force, i.e. being kicked, punched, etc.? Keep in mind that in a fighting game the character has many animations, at least 20-30, if not more. In addition, since it's one-on-one fighting, the enemy would also need to have many animations and be able to handle collision and so forth. I've done some research on the subject and here are the options I've come up with:
 

  1. A rigidbody with isKinematic set to False for the whole character and a mesh collider over the whole character. The problem with a mesh collider is that it's not meant to be used for animated objects (I think). It's mostly for static, simple geometry. In addition, a mesh collider cannot collide with another mesh collider, unless its Convex, but in that case it cannot have more than 250 or so triangles (an animated 3D character has thousands of triangles).
  2. A rigidbody with isKinematic attribute set to False and mesh colliders for each body part, i.e. head, arms, legs, torso. Similar problem with #1 above. Mesh collider is not for animated objects.
  3. A rigidbody with isKinematic set to False and a primitive collider for each body part, i.e. sphere for head, capsule for arms and legs, cube for torso. This would allow for detecting collison for each body part, which is essential for fighting game mechanics.
  4. Same as above, but also add a separate rigidbody to each body part as well.

So far I am leaning towards option #4, but I would like to hear some educated opinions from people on here more experienced than myself.

Thanks.


Edited by lougv22, 22 March 2014 - 08:07 PM.


Sponsor:

#2 dribble04   Members   -  Reputation: 150

Like
1Likes
Like

Posted 24 March 2014 - 12:21 AM

You don't need to use any rigid bodies, or mesh colliders to accomplish what you are trying to do.

 

Street Fighter like games are usually done with bounding boxes, now based on whether you want 2D or 3D collision, you make the boxes 2D or 3D. In unity just set the 'z' size of a box collider to 0, for 2D and for 3D you can manipulate the z based on how wide your model's appendages are (arms, legs, torso, etc..)

 

Write a simple AABB collision detection, as your broadphase, and process your animations, action, reactions, based on this result. 

 

Am not sure but, I guess if you wanted to use forces at exact collision points, you won't have to process your narrow phase, just grab contact point from Unity itself, and you could use rigid bodies, and toggle between isKinematic. But I don't think that's required. 

 

Street Fighter, and games alike are heavy in terms of their AI, and managing their attack and defensive strikes, with the use of a FInite State Machine (FSM), the responses are handled solely by the animations based on who's hurt box has collided with who's hit box first. 



#3 ferrous   Members   -  Reputation: 2075

Like
1Likes
Like

Posted 24 March 2014 - 02:05 PM

Yeah, most fighting games have zero physics, everything is canned and uses simple bounding volume collisions.

 

I've always thought it would be fun to see a more physics driven fighter, where fighters actually aim at their opponents, and the forces are calculated and determine the level of reaction.  It's always bugged me that in every fighting game, the fighters always punch the same, even when they are facing against a taller or shorter opponent.  Fighters aim for jaws, legs, etc, they don't just kick the same spot in the air.  And when they hit or get hit they react, stumble, etc, but instead every fighting game tends to just play a canned hit animation, and tries to cover up the fact the punch didn't land that near their opponent by playing a little flashy pow/bang/whizz affect on top of where the collision boxes collided.



#4 lougv22   Members   -  Reputation: 226

Like
0Likes
Like

Posted 27 March 2014 - 07:50 PM

Thank guys, for both of your replies. I had no idea fighting games don't use proper physics and that they handle everything with animations. Doesn't that increase the amount of animations significantly and wouldn't it be simpler and less computing resources intensive to use rigidbody (or some other) physics instead? I guess not, otherwise that's what they'd probably do smile.png

 

@ferrous,

 

That's actually a pretty good idea. I've no idea why no one has done it yet. It might be too complicated to do.

 

Can anybody else provide any more feedback, comments, and/or advice on this?


Edited by lougv22, 27 March 2014 - 07:52 PM.


#5 ferrous   Members   -  Reputation: 2075

Like
0Likes
Like

Posted 27 March 2014 - 08:03 PM

There isn't really an increase in animations though.  Like I said, all characters use the same punch animation regardless of their opponent, all the characters tend to have just a handful of "Got hit by an attack" animations.  In fact, I think the older Street Fighters just have one, maybe two.  One tends to not notice because they place a small effect at the location of the intersection of the hit boxes, and the recovery from that hit is quite fast.  Now, they might give the character some sort of velocity or what have you, but it would be very canned, and a rigidbody would overkill in that case.  Ie, if hit by a strong attack, they might get imparted with a greater velocity than a light attack, but it's pretty easy to calculate that without a rigidbody, and gives them greater control of just how far each attack will cause the character to fly.  Either way though, just the single "Got Hit" animation is played for either attack.

 

Oh also, from the attacker's side, the attacker doesn't play a different animation whether the opponent blocked, was hit or was missed entirely.  The same attack animation, the same number of frames, etc.  (Another thing that slightly bugs me, as whether I hit or miss my kick, whether it was blocked or stuffed, all drastically changes my motion, and what moves are more easily available next.)

 

I think I stopped playing fighting games after I started sparring a lot.


Edited by ferrous, 27 March 2014 - 08:16 PM.


#6 lougv22   Members   -  Reputation: 226

Like
0Likes
Like

Posted 27 March 2014 - 08:41 PM

I see. That clarifies it a lot. I guess they are going for biggest bang for their buck. It would definitely be more realistic they way you describe it, but in games realism is not necessarily the same as fun. And fun, IMHO, is much more important than realism. One of the basic tenets of my game design philosophy has always been that games should be authentic, not realistic.

 

In the case of fighting games this holds true as well. I do martial arts, and spar, as well, but I don't know that making a fighting game's mechanics more similar to real-life sparring would necessarily translate into more fun for the player. It would definitely be something interesting to try though.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS