Search Unity

  1. Engage, network and learn at Unite Austin 2017, Oct 3 - 5. Get your ticket today!
    Dismiss Notice
  2. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  3. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  4. Unity 2017.1 is now released.
    Dismiss Notice
  5. Unity 2017.2 beta is now available for download.
    Dismiss Notice

Top down view collision with different ground height.

Discussion in '2D' started by braykin08, Sep 14, 2017.

  1. braykin08

    braykin08

    Joined:
    Sep 14, 2017
    Posts:
    2
    Hello guys,

    I'm working on a dungeon crawler, let's say the Zelda bit of dungeons.
    Now, I'm struggling on the notion of height in a 2D view, how can I make collide the player with the ground that is one or many level higher, but he can drop on level lower
    Here is a sketch#1 of what I mean. Green arrow means he can do it, red means he doesn't.

    Also, the high ground may be a single tower, so it must collide from all direction.
    To get on those higher ground, sometime there will be stairs and sometime it will be a "jumping pad" that will consider the player as one level higher.

    I have tried using layers, but they are two ways so I can't stop them from climbing.
    I also tried placing the "platform effect" to act as a one way collider, but since I need all 4 directions it would be a mess to use.

    Is there any way to make it easy to simulate different height like this?
    Thank you
     

    Attached Files:

    • 002.png
      002.png
      File size:
      15.9 KB
      Views:
      9
  2. jeffreyschoch

    jeffreyschoch

    Joined:
    Jan 21, 2015
    Posts:
    1,937
    One solution would be to put a trigger on the top side, or otherwise detect the collision and check the direction, and then move the character down through the collider with an animation or something, briefly disabling the player's physics.
     
  3. braykin08

    braykin08

    Joined:
    Sep 14, 2017
    Posts:
    2
    Essentially, it would be to rework Unity's physic and moving them myself instead of using the rigidbody behaviour?
     
  4. jeffreyschoch

    jeffreyschoch

    Joined:
    Jan 21, 2015
    Posts:
    1,937
    Only for the brief moments when the player is jumping down the cliff.
     
  5. Nkoeppel

    Nkoeppel

    Joined:
    Oct 28, 2016
    Posts:
    86
    In zelda it was just an animation when you walked up against the cliff, I do it by sending a box cast to my target jump point and if its clear I allow my player to jump with its collider disabled until it lands.