Search Unity

Enemy-Player Collision in 2D game: suggestion request

Discussion in 'Editor & General Support' started by KarelVR, Apr 12, 2010.

  1. KarelVR

    KarelVR

    Joined:
    Oct 12, 2005
    Posts:
    51
    Hi !

    I'm working on our 2D game, and have a bit of an issue.

    The player has some colliders attached to him, and so do the enemies.
    This works ok to block the player from going left or right.
    But when the player jumps he can land on the enemy's head and keep standing there, and that's something I'd like to avoid.
    Here's an image to make the issue clearer.

    Does anyone have any suggestion on how to avoid this mess ? I'm not looking for a complete solution, if you could just point me in a rough direction that would be totally awesome!

    Thanks !

    Karel
     

    Attached Files:

  2. Ramen Sama

    Ramen Sama

    Joined:
    Mar 28, 2009
    Posts:
    561
    My first thought would be an additional collider on top of the enemy that only blocks out player objects. Aside from that, perhaps some raycast down diagonally while the player is jumping, if it hits an enemey, forward movment is halted.