Search Unity

2D RPG (Zelda Like) Jump System

Discussion in '2D' started by dojbouli, Jun 12, 2016.

  1. dojbouli

    dojbouli

    Joined:
    Jun 12, 2016
    Posts:
    2
    Hi Everybody !

    I'm using Unity 2D system to make a RPG Game (Top Down) like the old Zelda.
    I implemented many features but I don't know how to make a jump system. (Same System of Alundra)

    I did a jump system... Animation + Bool Jump... When I'm jumping The Box Collider of my obstacle is desactivated and when I leave it The Box Collider is activated...

    But I don't think this is the right way to do this... Have you got any advices ? Or an example ? Or a video tutorial ?

    Sorry for my english !!!
     
  2. Hyblademin

    Hyblademin

    Joined:
    Oct 14, 2013
    Posts:
    725
    I don't think that's a great approach, because things that are still on the ground won't be able to interact with each other any time the player is jumping, because all of their colliders will be turned off. If you want to be able to jump over enemies as well, then when the player is jumping they'll be able to walk through walls, etc.

    Try this:

    -Make three collision layers. One is for grounded objects, one is for airborne objects, and one is for objects that exists in both planes (for tall objects, like trees or columns, or massive enemies).

    -Set the collision matrix so that the Ground layer and Airborne layer do not interact, but both interact with the Tall layer.

    -Give your player both a Ground collider and an Airborne collider, and deactivate the Airborne one. When your character jumps, toggle both colliders to switch collision states. Toggle them both again when the player lands on the ground.

    You can give only Ground colliders to obstacles that stay on the ground, and give both types to enemies that can jump, or obstacles that otherwise can impede the player in the air. Give Tall colliders to things that block the player, but can't be jumped over. You can even give only Airborne colliders to things that block the player only if they are jumping.
     
  3. dojbouli

    dojbouli

    Joined:
    Jun 12, 2016
    Posts:
    2
    Ty for ur advices Hyblademin.

    I tried it and it works pretty good.
    I have to redo a part of my code but it's ok.

    The hardiest part will be to make a fake multiple levels... (like doing a fake stair...)
     
    Last edited: Jun 13, 2016
  4. isdinegnorra

    isdinegnorra

    Joined:
    Jul 21, 2019
    Posts:
    2
    hi bro, i have the same problem in my project .. please can you give me more information about your way to solve it..
    if you have a script it's will be good.. thanks
     
  5. RichardKain

    RichardKain

    Joined:
    Oct 1, 2012
    Posts:
    1,261
    Well, for starters, you should probably have a "root" position object that serves as the character's base transform position. Then you should have a separate object with a child relationship to the root object, and that object should have the collision detection assigned to it. (possibly the sprite display as well) "Jumps" should simply be a basic in-game animation where the child is animated relative to the parent.