Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Beat-em Up Movement

Discussion in '2D' started by MasqueNoMercy, Nov 28, 2014.

  1. MasqueNoMercy

    MasqueNoMercy

    Joined:
    Apr 26, 2014
    Posts:
    5
    I have been trying to figure out how a beatemup type game's movement would work in unity (like streets of rage or turtles in time or scott pilgrim or castle crashers). It would be a 2d game but also moving along that z axis. Does that mean that it should be a 3d game with sprites or a 2d game with custom z and y axis control, which confuses the heck out of me if i want jumping too. I don't really even see any tutorials on the subject that includes jumping. Can someone put me on the right track?
     
  2. GarBenjamin

    GarBenjamin

    Joined:
    Dec 26, 2013
    Posts:
    7,441
    Those games are unique in the sense that y position represents depth and as you mentioned also represents vertical position for jumping. Basically all you'd need for 2D is to track real y position. Which only corresponds to when feet are on ground. That's your value for depth knowing in which order to draw things. The jumping would effect where the sprite is actually displayed vertically but would not change the depth. Basically think of jumping and being knocked up into the air as an offset. So a Vector2 could hold the position x and real y. Then add any jump or knockback y offset to that value. But always keep another Vector2 of the character's actual ground position. That would work with an automated physics system like Unity. Use the v2 corresponding to ground position for draw order.
     
  3. Anderson-Taborga

    Anderson-Taborga

    Joined:
    Nov 12, 2012
    Posts:
    2
    Could you provide an example?
     
  4. Brainswitch

    Brainswitch

    Joined:
    Apr 24, 2013
    Posts:
    270
    Why would you need two Vector2s? It's not a 4D game ;P (I think you meant a Vector2 for 'main'/'ground' position and a float for vertical offset - like jumping or knockback)

    I'd use Unity's 3D physics engine for a beat-em up game, regardless of visual representation (ie 2D sprites or 3D models). Then jumping would not be an issue.
     
    GarBenjamin likes this.
  5. GarBenjamin

    GarBenjamin

    Joined:
    Dec 26, 2013
    Posts:
    7,441
    Exactly. You wouldn't need to use a vector2 for the yoffset and a float would work. I'd probably use a Vector2 to begin with just in case I wanted to do some kind of x offset effect at some point.
     
  6. Brainswitch

    Brainswitch

    Joined:
    Apr 24, 2013
    Posts:
    270
    Couldn't the x offset effect use the 'main' Vector2?

    Still, I recommend 3D physics for such a game. Especially if one is planning to have platforms/bridges/etc.