Login / Registrieren
DE EN FR ES IT CZ
Zurück Nach oben

How to draw hit boxes?

  • #1, de nerd h 7 years ago Zitieren
    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.
  • #2, de Nigec h 7 years ago Zitieren
    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 
  • #3, de Nigec h 7 years ago Zitieren
    PS
    AFRLme gets all the credit, its stuff he's told me smile
  • #4, de nerd h 7 years ago Zitieren
    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.
  • #5, de Nigec h 7 years ago Zitieren
    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
  • #6, de afrlme h 7 years ago Zitieren
    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?
  • #7, de nerd h 7 years ago Zitieren
    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?


  • #8, de Nigec h 7 years ago Zitieren
    check were they are

    local benishere = getObject("Characters[Benny]"):getPoint(VCharacterPosition)
    
    print(benishere.x, benishere.y)
  • #9, de nerd h 7 years ago Zitieren
    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
  • #10, de afrlme h 7 years ago Zitieren
    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).
  • #11, de nerd h 7 years ago Zitieren
    Thank you