How to draw hit boxes?

  • #1, by nerdWednesday, 12. December 2018, 16:53 6 years 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 6 years 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
    You can also set the animation to run from a start frame to an end frame like:
    setAnimFrames(animname, int , int)
    function setAnimFrames(anim, first, last)
    
    ActiveAnimations[anim].FirstFrame = first
    
    ActiveAnimations[anim].LastFrame = last
    
    end 

    Key Killer

    640 Posts

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

    Key Killer

    640 Posts

  • #4, by nerdThursday, 13. December 2018, 09:05 6 years 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 6 years 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

    Key Killer

    640 Posts

  • #6, by afrlmeThursday, 13. December 2018, 11:20 6 years 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

    7285 Posts

  • #7, by nerdThursday, 13. December 2018, 11:31 6 years 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 6 years ago
    check were they are

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

    Key Killer

    640 Posts

  • #9, by nerdThursday, 13. December 2018, 13:09 6 years 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 6 years 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

    7285 Posts

  • #11, by nerdThursday, 13. December 2018, 13:27 6 years ago
    Thank you

    Forum Fan

    147 Posts