Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Jumping in a 2D Space - Streets of Rage

Discussion in '2D' started by mac_l64, May 13, 2020.

  1. mac_l64

    mac_l64

    Joined:
    Dec 2, 2018
    Posts:
    2
    Hi community,

    Hope everyone is well and safe.

    Currently doing some research on how I might implement jumping in 2D games with a 'beat-em up' style camera perspective (image below is of Streets of Rage 4 as an example). Given that the X-axis is reserved for moving left and right and the Y-axis is reserved for moving up and down, my key questions is: how might jumping be implemented within Unity given the 2D constraints?

    There are several ideas I have been attempting/ contemplating, such as:
    • Making the appearance of jumping purely aesthetic and therefore have no impact on movement. Jumping would purely be an animation change
    • Using 2D sprites in a 3D space and therefore use the Y-axis as normal (given Z is now available for up and down movement)
    I wondered if anyone else had any thoughts and insights to share.

    Many thanks


    Streets of Rage 4​
     
  2. Ruskul

    Ruskul

    Joined:
    Aug 7, 2014
    Posts:
    72
    First, I would never make a jump only have an aesthetic purpose unless I was trying to make an anti game to piss players off. Every player would assume that a jump has a purpose rooted in physics. How would you feel if a rattlesnake popped out of the grass as you were walking along. You try to jump it but that just resulted in meaninglessness. You got bit, even though it looked like you should missed it. But, if i misunderstood what you meant by purely aesthetic please correct me.

    It's basically "3d" no matter how you dice it. Think about an old zelda game. You can go up and down, left and right, but in some of them, you can jump. You simply add one more variable to the character that is their jump height, and that 3rd positional variable makes it "3d". All calculations are done in 2d and for the collisions that are found a final test comparing jump height (zelda) or depth/in-out (streets of rage) is conducted. Then when you go to draw the actual sprites, they are offset by the 3rd dimension variable. Basically, to the game engine, all the assets are still in a single plain, but on screen, to the player, it is 3d. Basically, you can simulate the world how ever you wish, but at a point, you have to translate that information to the screen. Just figure out what would be efficient/easy to program the game in and then use magic to render it however you wish.
     
    Last edited: May 14, 2020
  3. Th0re

    Th0re

    Joined:
    Sep 4, 2015
    Posts:
    39
    The scene is always 3D. The problem is not jumping but whether to use the default collision (3D) or collision 2D suite, which is a game design question. Both works, and depends mostly on whether the game surface is virtually always level (typically is in such games) or if there are platforms of sorts.

    It looks like the whole thing has a flat level design, in 2D, orthographic camera with carefully set colliders. The jump is merely a way for an extra set of combat moves but since the level is flat, you never need to jump onto/over something. Jump can be animation: the holder object stays where it is, but the character sprites and hit collision stuff is animated inside the holder, so it looks and behaves correctly (animation does not mean it behaves wonky). Jumping over or onto something can still be added, if it is essentially just aesthetics.

    If your game has platforms, elevated areas and such, and the physics of the space is relevant, you could consider 3D collision. Tilt the camera for the angle, and create the 2D look with camera-facing sprites and orthographic camera. But then you get potential issues like flying-kicking but “missing” on the z-axis, because your character is too far to the background or foreground. These games typically use “arcade physics” where when the fist meets the chest or head area, it’s a hit, perspective be damned. This can be done in 3D space too, but you must pick the right perspective and sprite sizes, depth of the level and so on.

    You can also mix and match in all sorts of ways.
     
  4. mac_l64

    mac_l64

    Joined:
    Dec 2, 2018
    Posts:
    2
    Hi and thanks for your response. Just to clarify the aesthetic point, I meant this purely as a matter of camera perspective as I know some older games employed techniques like this. Visually, sprites, shadows, scaling, would create the illusion of jumping, but in effect no impact on the transform of the object would take place. Th0re's response sums this up. Definitely given me a lot of ideas to experiment with and it was. The game will not contain elevated areas conveniently. One idea I prototyped was simply using 2D sprites with 3D colliders in a 3D space. For the most part, this seemed to work okay. Hugely appreciate both of your help.
     
  5. Ruskul

    Ruskul

    Joined:
    Aug 7, 2014
    Posts:
    72
    Oh, I understand, thanks. That makes a lot more sense then and you are right, Th0re summed it up nicely.
     
  6. athgen113

    athgen113

    Joined:
    May 25, 2018
    Posts:
    46
    look good , when you make it .