Search Unity

Basic Fighter Template

Discussion in 'Works In Progress - Archive' started by dibdab, Jan 25, 2017.

  1. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    close-combat fighting system

    designed for game-pad control
    it has 4 leftKnocks 4 rightKnocks 4 leftKicks and 4 rightKicks
    (can be modified in animator controller by changing clips)

    basicfighter2.gif

    features:
    * it keeps tracks of which bodypart hit which bodypart of the opponent
    * calculates at which angle was the opponent hit

    check out the windows demo
    http://www.mediafire.com/file/6oq33dy6j32zljs/basicfighter_demo.zip
    GAMEPAD REQUIRED
    front Right/Left lower buttons + WNSE : Kicks
    front Right/Left higher buttons + WNSE : Punches
    F button for Get Up


    basicfighter3.gif


    in the demo used
    Bouncer/Tough Guy from Studio New Punch
    animations
    for reaction from Mixamo
    Fighting Motions Vol.1 from
    Magicpot Inc.
     
    Last edited: Feb 10, 2018
    Antypodish, user099 and theANMATOR2b like this.
  2. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    started to re-do this system

    fighter.gif
     
    Last edited: Feb 10, 2018
  3. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    the new thing is that
    both fighters know every parameter of the attack (when the hit happens)
    and system only registers hits made by the attacking limb

    most of it is self-explanatory, just
    1. angle + side is from the attacking transform
    2. angle + side is form the attacker hip
    stopped means attacking animation stopped when registering hit

    fightera1.jpg
     

    Attached Files:

    Last edited: May 17, 2018
  4. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    the problem with the angle was that the bones could be anyway rotated and mess up orientation
    so the angle is calculated now based on the attacked fighter's hip

    fighter2.gif
     
  5. Ur_anus

    Ur_anus

    Joined:
    Mar 1, 2018
    Posts:
    2
    Can you update the system so that the player can punch, kick, block and dodge the hits?
    That way we'd get a good fighting system and can you add AI to the game?
     
  6. Ur_anus

    Ur_anus

    Joined:
    Mar 1, 2018
    Posts:
    2
    Can you add these features to the game? Here's the list:
    - Standing movement
    - Crouch movement
    - Punches
    - Kicks
    - Hits
    - Knocouts
    - Get ups
    - Blocks
    - Dodges
    - Jumps
    This way the fighting system will be complete
     
  7. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
  8. CuriousScribbles

    CuriousScribbles

    Joined:
    Jun 24, 2015
    Posts:
    28
  9. Firlefanz73

    Firlefanz73

    Joined:
    Apr 2, 2015
    Posts:
    1,316
    Looks cool :) How about blunt / melee weapons?
    Will this be available as an asset?
     
  10. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    yes, will submit to the store when ready.

    the same mechanics work for weapons, just like bodyparts.
    just probably would want to pass along that it's a weapon for different reactions, damage etc
     
  11. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    nu makehuman fighter

    with Mindfront's CC0 textures and jimlsmith9999's
    fighter01a.jpg
    fighter01b.jpg
     
    Last edited: Sep 29, 2018
  12. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    it's not easy to find good animations that can be distributed
    but don't want it to fell like a half-cooked fighting
    so trying to find a good selections of animations

    from the cmu archive
    punches
    punch8.gif punch9.gif punch11.gif punch13.gif
     
    Last edited: Sep 29, 2018
  13. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
  14. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    and blocks and dodges
    block1.gif block2.gif dodge1.gif dodge2.gif
     
  15. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    kicks from the cmu
    kick1.gif kick2.gif kick3.gif kick4.gif

    and some extra from the mocaputd archive
    elbow1.gif
     
  16. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    don't know how these short anims will work with transition
    dodge5.gif dodge6.gif
     
  17. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    and these type of step anims will be crucial for player orientation/movement
    step1.gif step2.gif step3.gif step4.gif
     
  18. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    there's a rootmotion issue in transitioning anims (version: U5.65), that it sinks into ground
    animseq0.gif
    it can be corrected with capsule collider+rigidbody
    animseq1.gif

    but if you know something about this, please tell
     
  19. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    started to rework ikControl

    this is 3 target positions
    ikpunchin.gif
     
  20. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    animstate footIK looks like a must (the feet are shaking without it)
    footik.gif
    to punch towards approximately the same place, body rotation offset needs to be modified
    (though there's a root motion rotation anyway, probably will need animation to transition back)
    bodyorientoffsets.gif
     
  21. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    added a timer thingie so this wouldn't happen
    getkey.gif >> getkeytimer.gif
    but you can see those abrupt root rotations
    so offset must be baked
    bakeintopose.jpg
    bakedoffset.gif
     
  22. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    first steps of the aiFighter turning towards player
    aifight01.gif aifight02.gif
     
  23. HeadClot88

    HeadClot88

    Joined:
    Jul 3, 2012
    Posts:
    736
    Let me know when this goes live on the asset store. @dibdab
     
  24. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    okay and thanks.

    some progress for aiFighter
    aifight04.gif aifight05.gif
    and a test for hit stop
    hitstop.gif
     
  25. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    experimented with blend tree changing animations.
    but they jump when blend parameter is changed during animation or transition, so it's hard to play them smooth.

    the good thing is, this system supports any number of animations for one fightmove
    so, made with animstates, attached how the animator looks now


    this is left/right side changing in action
    added a figure display too


    leftright.gif

    ...............................................................................
    also if you've been thing about it,
    now you can buy my other assets at reduced price
    car package15 and flight sim
    when I submit this package they'll return to regular price
     

    Attached Files:

  26. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    another pre-requisite
    gravweight.jpg
     
  27. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    Last edited: Oct 19, 2018
  28. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    webdemo updated to the final first version

    added sound and turning
    webdemo.jpg
     
    FreakForFreedom likes this.
  29. Raketeers

    Raketeers

    Joined:
    Dec 16, 2017
    Posts:
    1
    Can you let me download the scripts and the project? By the way can you make this package free?
     
  30. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,770
    Fantastic work. Keep up.

    Do you think you will be porting / adapting your system, with upcoming new character animation system? Probably Unity 2019?
     
  31. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    I think kinematica is fundamentally different system, but if they keep it old-school (no deep/virtual methods, or ecs-type of scripts) then it might be compatible, since the walker part is separate from the fighting (which animations can be triggered just like others) and the hit detection has some things that uses from fightMechanics.cs.

    probably it could be done if any outside animation can be called alongside the new animation system, since the reactions part is not driven by control/keyboard etc

    there's no plan to release it free, but the package will not cost much
     
    Antypodish likes this.
  32. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    I've been working on IK before submitting.
    hitik7.gif
    changed it a bit, that want to explain.
    wanted to have a set of iktargets that are set and unchanged (most IK-solutions use effectors/targets set in editor)
    and make them follow 'dummy' targets that change when IK is used.

    there's two kinds of iktargets:
    one that is placed in skeleton hierarchy (usually second hand when holding gun)
    or one in world space (like hitting body)


    for situations like this
    hitik3.gif

    I made changes so that it registers hit even when there is no fightmove attack,
    to have a hit detected:
    must be attacking (needs animation event setAttackOn and setAttackOff, I tend to forget)
    and the attackside (of the attack and the hit-detector) must match

    these are to ensure that only attacking hits are registered and not any move
    so if you see hits not detected, look into those two first.

    because any move can go across other body (if reaches beyond the capsule and is not registered as attack).

    or can be used not for IK, but to trigger move reaction from the other actor

    though many times doesn't look good, and therefore it can be turned off (bool stopcrossed)
    here's a bad example
    hitik5.gif
    this might look better with the adjusting variables
    - time to start ik-weight decrease
    - speed of decrease
    though the chest collider is a bit low and also
    greater precision could be reached by more hit-detectors
    so the hand would stop sooner

    and here's an attackmove example
    hitik9.gif
     
    Last edited: Nov 1, 2018
  33. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,770


    Should target hit body turn actually left, rather than right?
    The upper left arm is hit, so makes sense for body to turn left.
     
  34. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    there is an angle and impact vector calculated then animation is played by the vector

    also possible to play reaction by hit bodypart (for example head)
    Code (CSharp):
    1. if (attackedobj.name == "head")   fmAttacked.damageReact.playHeadHit ();
    the angle is calculated between
    1. attackedhip and attackerobj (handR)
    2. attackedhip and attackerhip

    checking with hip was more reliable, but they are compared and
    there is an impact vector calculated between
    1. attackedobj and attackerobj (if the angles match)
    2. attackedobj and attackerhip (if they don't match)

    might be changed in future

    what you saying, could be done by
    checking position of the attacking hand at the hit
    and calculate angle by attackedhip
     
    Antypodish likes this.