Search Unity

OnTriggerEnter for melee fighting system?

Discussion in 'Physics' started by Larpushka, Aug 16, 2020.

  1. Larpushka

    Larpushka

    Joined:
    Jan 6, 2015
    Posts:
    214
    So does OnTriggerEnter for a melee fighting system sounds like a good idea? Basically I put the trigger on the swords/shields. So far I can't say it's been working magnificently, I have some bugs but question is if as a base it's a good framework for a medieval melee fighting system. Uploaded a gif showing what I did so far.
     

    Attached Files:

  2. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,073
    No from my experience it is totally wrong. With fast weapons/fps you will have tunneling without OnTriggerEnter registering.

    I'm myself creating melee fight in my game, right now I'm experimenting with ray casts and it is still far from acceptable.
     
  3. Larpushka

    Larpushka

    Joined:
    Jan 6, 2015
    Posts:
    214
    Thanks for the "tunneling" term, I was not aware it can happen. I suppose that if I keep the motions slow it should be ok then.
     
  4. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,073
    You might try, but this is kind of a lottery.
     
  5. Larpushka

    Larpushka

    Joined:
    Jan 6, 2015
    Posts:
    214
    I'm afraid so far it didn't turn out too well, triggers don't seem to like speed. Here's my result after rehashing the scripts/animations


    Does anyone wanna chime in with another idea?
     
  6. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,073
    I was cheering for you but I was expecting it to happen.
    Unfortunately physics kind of sucks in what it is supposed to do.
    So I think you will have to try the raycasts after all.

    Chose points along the edge of your sword - density depends on the smallest objects you will be hitting, and do raycasts from previous positions to current positions.
     
  7. Larpushka

    Larpushka

    Joined:
    Jan 6, 2015
    Posts:
    214
    Thanks for the advice but I'm worn down by all the work it requires. Not worth it. I'm trying to do something more creative (=easier) with the fighting system at the moment so I've abandoned the live-action style.
     
  8. scifresh

    scifresh

    Joined:
    Oct 8, 2013
    Posts:
    23
    How would go about doing this ? Do you have some kind of a sample of this approach ?
     
  9. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,073
    You can search for "Mordhau" medieval multiplayer game development blog i think they are explaining it there.