Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

2.5d horizontal collision

Discussion in 'Physics' started by Zordnael, Sep 23, 2019.

  1. Zordnael

    Zordnael

    Joined:
    Jul 4, 2019
    Posts:
    2
    Hello!

    I'm making a 2.5d side-scroller fighting game. Actually, I'm remaking Little Fighter 2 using unity just for practice.

    In Little Fighter 2, heavy objects have a strange collision with characters in which the characters only colide horizontally. The collision is quite weird, because if you insist in colliding with the object you can eventually get through it. It also seems like the collision only works if the character is located on the side opposite to its movement.

    Its complicated to explain it with words, but I hope that you can see it in the following video:



    Does anyone have a good idea for implementing such a collision?

    Thank you!
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,161
    The video doesn't really help, need some info like is this 2D or 3D physics, showing or describing the actual colliders themselves, explain how the characters are moving and detecting collisions, what the rigidbody body-types are etc.
     
    imforshizley likes this.
  3. Zordnael

    Zordnael

    Joined:
    Jul 4, 2019
    Posts:
    2
    Ok! I'm sorry, I intended to have audio explaning everything on the video, but my mic broke. Let me see if I can explain everything asked. English is not my native language, so bear with me please!

    The game has 3D physics, everything uses box colliders only. It's a ortographic view of a 3D world using 2D characters.
    In my game, there is a box collider:
    1. For the body (that serves as the "hurt"boxes and as a collider for the rigidbody with the "ground" layer of objects only).
    2. For the hitbox (that is a trigger only box collider for damaging and interacting with other things).
    3. For the item check box (that is also a trigger only box collider and it is used to check if there is a body of an item in reach for the character to grasp)

    Both of the body and hit boxes are animated and change its properties (size, center and enabled) depending on the animation.
    In my game, I use the body box collider for my rigidbody to collide with the floor and keep everything on the ground (it's not trigger only). But the hitbox is trigger only.



    The video is not from my game, but from Little Fighter 2. I want to simulate the behavior shown in which the heavy objects (such as the stone) stops the character from moving on the Z and X coordinate, but not Y. Meaning that the character will not be able to walk through it, nor be able to land on top of the stone.

    In Little Fighter 2 there is only a body box and a hitbox. In their case, they use a "hitbox" on the heavy objects with the same size and center as the body when the object is immobile on the ground to keep the characters from getting closer to it. They also use the "hitbox" to check for items, and other interactions. But I don't really need to use the same box collider to do this things, I can just create another colliders... Anything that would replicate the behavior shown in the video and described here.

    Can someone help me with a good solution for this?

    Thank you!
     
    ivytin likes this.