Search Unity

Idea for 2D RPG jumping

Discussion in '2D' started by dccoo, Oct 3, 2015.

  1. dccoo

    dccoo

    Joined:
    Oct 3, 2015
    Posts:
    161
    Hello, everyone.
    I'm trying to make a 2D RPG, where you look at your character from an angle like SNES RPGs, like chrono trigger, secret of mana, legend of zelda, etc.
    The problem is: As I'm using 2D, the "real" jumping would be in Z axis, you know? cos' X is horizontal and Y is vertical... but if I add some force at Z axis, the character jumps towards the screen, that means he doesn't seem to jump even if he's in the air, cos the jump cannot be seen.
    The only idea I had was to add force somehow the character could change it's Z and also it's Y, so now, changing the Y (moving little vertically) it would be clear that he was jumping, but if I move in Y, I won't be able to fall in the same place I jumped...
    Any ideas on how to implement this jump?
    Thank you
     
  2. Stef_Morojna

    Stef_Morojna

    Joined:
    Apr 15, 2015
    Posts:
    289
    I would do the physics in 3d, but still use a Orthographic camera so it still looks 2d.
     
  3. dccoo

    dccoo

    Joined:
    Oct 3, 2015
    Posts:
    161
    The 2D mode is 3d with an orthographic camera ...
     
  4. GazingUp

    GazingUp

    Joined:
    Jun 16, 2015
    Posts:
    271
    It's actually a lot more fun to have control over the physics of the entire world, versus simply using 3D to imitate a 2D world.
     
  5. GazingUp

    GazingUp

    Joined:
    Jun 16, 2015
    Posts:
    271
    I have accomplished this actually and trust me you'd want to figure this one out on your own. I will give you hints though:

    It's all about sorting layers, 2D Collider detection, and the Y Axis of the player sprite. Also observe how shadows move from ground to platforms (Eg: Observe Super Mario Superstar Saga) and you will see a pattern.
     
    wlwl2 and dccoo like this.
  6. dccoo

    dccoo

    Joined:
    Oct 3, 2015
    Posts:
    161
    don't you wanna give me more clues? I havent figured out how the rendering order works, for example if you are in a situation like this
    upload_2019-8-7_22-36-5.png
    in the same y position, the player could be over the platform or behind it.
    how would I decide it?
     
  7. GazingUp

    GazingUp

    Joined:
    Jun 16, 2015
    Posts:
    271
    I wanted you to have the fun in discovering this yourself. I will shed some more clues and a gif of what I got so far.
    https://gph.is/g/ZYAwKW1
    I am still having many bugs here and there but the main issue isn't code related but with colliders. Maybe once I get down to the basic jumping on platforms bug free (For example when jumping from a platform below to a platform above it snaps upwards onto the platform above.), I will figure a better workflow with some kind of collider resizing code based on the sprites.

    What I did for this was to place a trigger collider above the sprite, so when it jumps, detect it on the collider and increase the sprite's sorting order so it appears above the tile in the same Y Position. Oh if you haven't done this already, change the Graphics Transparent mode under Project Settings to custom axis and put a 1 to Y and 0 to Z. Makes stuff appear behind or in front of things based on Y.

    Control the appearance of the sprites based on the shadow's sorting order to tell differences between the heights.
     
    dccoo likes this.
  8. dccoo

    dccoo

    Joined:
    Oct 3, 2015
    Posts:
    161
    In fact I was able to make it work well, using only what you mentioned (sorting layers, 2D Collider detection, and the Y Axis), thank you! Looking at the game you said also helped me to figure out what was going on.