I’ve spent several months trying to get my characters to do melee damage. I have all of my animations down. Monsters can do damage to me on touch, but the only way I’ve been able to get my characters to do damage is with projectiles. What I’m wanting is damage that follows the structure of a sword or mac. I’ve tried using timeline but I can’t seem to understand how to properly use it with a time line, nor can I figure out how to attach collision boxes to just a few frames of a character with or without sockets. Could somebody please give me some more ideas to run with?
I’ve seen lots of people looking for answers to this question. And I’ve seen a few who had done it. But I can’t seem to find anyone who found answers other than those who figured it out themselves and even then it’s been quite some time since those people have been on AnswerHUB. Still trying to figure it out myself, and If/When I do I will certainly post here how I came to make this work so that others won’t spend as long as I have trying to find a solution. Hopefully someone who already has figured this out might lend some advice though? =)
Anyone? Only thing I’ve come up with is a projectile movement component that fires in time with my animation with a lifespan of 0. Is there a better way to pull this off or a way to make that movement trace an animation?
Super late, but better late than never
There are many options you can use, most of which I probably do not know. However it’s working fine for me the way I’m doing it, even if it’s not the best.
I’m having trouble understanding what your issue is (how would you use timelines for this? that doesn’t make sense to me. Only thing I used timelines for was sending the actor on the other end flying when struck). You could just use the already implemented per-frame collision built into paper2d. Just go into the flipbook and set the setting there.
Alternatively, you could do 3D box collisions like I am doing for my game since it is technically 3D.
Here’s a .GIF of the game:
That barely took me any time to implement. What I did was make a macro for each attack, and use that whenever my character attacks. The combo system is a different thing, but if you’d like me to explain that too then comment on that and I’ll do my best (not that hard).
So I made a function titled “Hitbox Adjuster” which when called resizes the collision box I setup around my player. This function is then called from within the macro to set the collision box’s size depending on what attack is occurring.
Here’s how simple it is:
In my case the Z isn’t changing, which is why it’ll always be 32.
Something I did was create an array with the actors that are currently overlapping that collision box. That way in my attack event/function I can loop through that array and apply the damage or whatnot to those actors. I then created an array of classes that my actor can hit when he slashes, and then I check if the overlapping actor belongs to any of those classes before adding them. And make sure to check that the object isn’t there already, as it might be added to the array twice and when the loop occurs it could trigger the events twice for that actor.
Here’s what it looks like:
I also created my own macro to detect when an animation has reached it’s end (and a few other options) by having it compare the current flipbook frame to the flipbook frame length every .01 seconds.
Then, I create a few variables titled “IsAttacking”, “CanAttack”, “IsAnimationPlaying”, etc. So here’s how it would work in my case (dumbed down, but you’ll get the basis):
Key Pressed → Turn Animation Looping Off → Wait for Animation End → Set “IsAttacking” To On → Set “IsAnimationPlaying” To On → Update Animation (animation state) → Attack Stuff.
I don’t know if I was clear enough, so let me know if I can help with anything else.
paragonx9, it would be awesome if you could share how you implemented your combo mechanics.
Wow, yeah, I had eventually given up and worked on other projects. I’ve just recently gotten back into the swing of things. I suppose I wasn’t understanding enough of the basic mechanics of 2d. I have gotten a lot farther now though, and I’m loving the way you did this. The combo system looks nice, and I can’t wait to get home and try this. Thank you so much paragonx9!
I know that this is an old posting, but I was wondering if you could post the example that you created for the melee so we could see all of the variable and marco’s that you created for the above example. Thanks
ParagonX9. I never thought i would see another person use Zero. You are awesome!
Can you please explain into more detail the combo and the collision system you’ve made? It’s really interesting.