Search Unity

I need help with my melee combat system

Discussion in 'Scripting' started by lemonrays, Jul 12, 2017.

  1. lemonrays

    lemonrays

    Joined:
    May 7, 2015
    Posts:
    48
    I've been scouring the internet all day long and I am still very perplexed by this. I hope somebody here can help me. My main issue is that child trigger colliders just don't like me. Or I'm doing something wrong. It's making my head hurt.
    Essentially, I am making a 2D top down melee system. The player character is surrounded by four different trigger colliders that turn on and off with a button press, depending on which direction they are facing, and this works fine. However, the main issue arises with the player receiving damage. There is a script attached to the player that determines their health. It looks for a collision with an enemy in order to take damage. The player activating their attack from a distance counts towards being hit by the enemy, however, as the attack colliders are children of the player. Obviously, the player taking damage from landing attacks is not the result I desire.
    Am I doing this all wrong? I really hate colliders and the fact that children colliders can never act as their own objects...
     
  2. lemonrays

    lemonrays

    Joined:
    May 7, 2015
    Posts:
    48
    Bumping.
     
  3. lemonrays

    lemonrays

    Joined:
    May 7, 2015
    Posts:
    48
    Anybody?
     
  4. BlackPete

    BlackPete

    Joined:
    Nov 16, 2016
    Posts:
    970
    So in a nutshell, whenever the player attacks, they're hurting themselves as well?

    It sounds like you're using the same colliders for both dealing out damage, and also for receiving damage.

    Am I understanding the issue correctly?