Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

First off, I am making a game similar to SSB, which relies heavily on physics, even though it is a sidescroller. I am currently using Unity.

In Unity there are "character controllers" which are used for characters that move, but they don't interact with other physics objects. There are also rigid bodies, which are completely realistic physics components. I can't figure out how to use rigid bodies for human/humanoid characters. Here's some questions I have:

  • How should I move the character? Applying forces is not the way to do it, right? Would you set velocities or pixel-by-pixel movement, perhaps?
  • What kind of collider should I use? I've been using a capsule collider. But is that the best way?
  • How do you make him not fall down!? After some experimenting, I discovered that the character falls over (from applying force/velocity and from the capsule collider tipping it over). Would you constrain the rotation in the Z-axis?
  • What do you do when he gets hit? If you've ever played SSBB you'll be familiar with this topic. I'm thinking that applying a force would be best in this condition? If you did constrain the rotation, would you un-constrain it?

    Ike punching link

share|improve this question
    
Mostly answered by Good 2D Platformer Physics. The answer seems to be: it's really ugly trying to get a physics engine to cooperate with something with requirements as strict as a platformer. You can work with a physics engine, but it's going to be tricky enough you probably shouldn't even want to. Write a simple physics engine that addresses your specific needs. –  Jonathan Hobbs Oct 16 '11 at 4:50

1 Answer 1

up vote 2 down vote accepted

How should I move the character? Applying forces is not the way to do it, right? Would you set velocities or pixel-by-pixel movement, perhaps?

Apply linear (and possible angular) impulse. The object retains velocity and imparts force to other objects on impact.

What kind of collider should I use? I've been using a capsule collider. But is that the best way?

The capsule collider is what you get with Unity, because it works well for most sorts of games. You could either continue to use it with adaptation (to the FirstPersonController script), or construct your character entirely out of bounding cylinders or bounding boxes (limbs, body, head etc.). The latter won't be as easy, but for a fighting game you'll have more accurate combat. I'm not sure this is really necessary as your game is actually 2D anyway, so benefits from this will be less than if your game were actual 3D.

How do you make him not fall down!? After some experimenting, I discovered that the character falls over (from applying force/velocity and from the capsule collider tipping it over). Would you constrain the rotation in the Z-axis?

Considering you're using rigid bodies, you're going to have to find some way to constrain, yes. It's either that or you switch between kinematic and rigid bodies at given times. The problem with the latter is you still need to know when the collision between your fist and the enemy's face occurs. So better to stick with rigid body physics throughout.

What do you do when he gets hit? If you've ever played SSBB you'll be familiar with this topic. I'm thinking that applying a force would be best in this condition? If you did constrain the rotation, would you un-constrain it?

Yes, apply a force; this could be as you switch the character back to rigid body mode (possibly based on where the character was hit, and for how much). In that case, when the character begins to recover, turn kinematics back on so he can stand up again.


NB What I've said above about using a mixture of kinematic forces and dynamic ones is one way to do it, and in some ways the easiest. However you can also purely use impulses with rigid bodies to control things. In my experience, this can be less than simple, so caveat emptor.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.