How to draw hit boxes?

  • #1, by nerdWednesday, 12. December 2018, 16:53 A year ago
    I got my character walking and punching, I was wondering how can I draw hit boxes during an animation to determine if an opponent is hit by the punch.

    Forum Fan

    147 Posts


  • #2, by NigecWednesday, 12. December 2018, 19:15 A year ago
    You would need to do it with lua
    function foo()
    local val = getObject(myanimation):getInt(VAnimationCurrentSpriteIndex)--get the current frame index
    if val >= 2 and val <= 20 then --range between frame 2 and 20
    --do stuff
    else
    --do something else
    end
    end
    1
    2
    3
    4
    5
    6
    7
    8
    You can also set the animation to run from a start frame to an end frame like:
    setAnimFrames(animname, int , int)
    1
    function setAnimFrames(anim, first, last)
    ActiveAnimations[anim].FirstFrame = first
    ActiveAnimations[anim].LastFrame = last
    end
    1
    2
    3
    4

    Key Killer

    520 Posts

  • #3, by NigecWednesday, 12. December 2018, 19:29 A year ago
    PS
    AFRLme gets all the credit, its stuff he's told me smile

    Key Killer

    520 Posts

  • #4, by nerdThursday, 13. December 2018, 09:05 A year ago
    Ok, basically the first script determine an action between a range frame right?
    This is useful for my propuse. But what I'd like to do also is drawing a invisible rectangle during animations, let's say mc punches, in the maintime the animation draws an invisible rectangle that if collide with another character it triggers its pain animation.

    Forum Fan

    147 Posts

  • #5, by NigecThursday, 13. December 2018, 10:37 A year ago
    I have no idea if you can create an action area on the fly.. it would be interesting to know

    Personally I'd just create my own regular one and have it visible on a set frame, and use values to determine what happens wih that value

    local cond = getObject("Conditions[myCondition]") --- get the condition of myCondition
    cond:setValue(VConditionValue, false) --if its true change to false

    local valA =(Values["myValue"].Int ) -- get myValue's value
    1
    2
    3
    4

    Key Killer

    520 Posts

  • #6, by afrlmeThursday, 13. December 2018, 11:20 A year ago
    you only really need to query if the 2 characters are x distance apart. in theory if both characters are close enough together then it should count as an hit, no? You could then expand upon that further, by querying a state/condition/value, such as characters are close enough together, but was the receiving character blocking/ducking/jumping?

    Imperator

    6773 Posts

  • #7, by nerdThursday, 13. December 2018, 11:31 A year ago
    you only really need to query if the 2 characters are x distance apart. in theory if both characters are close enough together then it should count as an hit, no? You could then expand upon that further, by querying a state/condition/value, such as characters are close enough together, but was the receiving character blocking/ducking/jumping?
    Yes this is the solution I was thinking too. Can you suggest me a script that checks if x and y position between mc and the opponent are in a certain range so that if mc play punch animation the opponent play a pain animation?


    Forum Fan

    147 Posts

  • #8, by NigecThursday, 13. December 2018, 11:33 A year ago
    check were they are

    local benishere = getObject("Characters[Benny]"):getPoint(VCharacterPosition)
    print(benishere.x, benishere.y)
    1
    2

    Key Killer

    520 Posts

  • #9, by nerdThursday, 13. December 2018, 13:09 A year ago
    I'd need a code like this but I've no idea how to do it:

    If opponent is distant x and y cordinate from player current position and player is playing punch animation then opponent play pain animation

    Forum Fan

    147 Posts

  • #10, by afrlmeThursday, 13. December 2018, 13:10 A year ago
    Answered in the other thread.


    As for your question, create an execute a script inside of the relevant punch animation frames. Best way for getting timing down.

    Alternatively you could use states (variable containing string words, such as "punching", "defending", "kicking", "ducking", "jumping", "idle", "moving", etc).

    Imperator

    6773 Posts

  • #11, by nerdThursday, 13. December 2018, 13:27 A year ago
    Thank you

    Forum Fan

    147 Posts

Write post