I’ve been puzzling about this for while now. I know of this concept through old fighting games from the 90s such as Street Fighter etc, using hitboxes or some form of collision.
Having a collision follow the player seems like a simple task, but I want to have the collision shape to change with the sprite or having it change depending on which frame its using. I’ve found that other people in the past have come across a similar problem and have posted on other forums. Going through the phaser 3 docs hasnt really helped me much.
I’ve also seen other forms of melee attack, which might rotate a rectangle to imitate a swinging a sword motion. I want to have a go at implementing something that involves collisions frame by frame of an animation such as in 90s fighting games that I grew playing as a kid.
I don’t have any running code. aside from other projects and things I’ve been learning. I don’t have the understanding of how to begin the code in Phaser 3 by any means.
I’ve watched this problem be easily solved in other software such as Godot, but that has a animation editor that can help handle that.
Here is a link to someone with a similar problem. here shadoworker made a tool designed to handle this problem but I think its before Phaser 3.
I’m hoping I can have a discussion on this. I would really appreciate any suggestions or help, or any thoughts from anyone who have accomplished this. Thanks.
I posted this on another forum but I should post it here.
Create a physics-enabled Zone for each box. Add overlap colliders to detect collisions.
Listen to the character animation start, complete, and update events and enable/disable, size, and offset the box bodies. Position the box bodies in scene update so they track the character body.
Okay. I can see how using a listener would help. I’ve been able to make a frameCount variable which will count the frames at a time. My hunch is to use a boolean operation that will set the size and position of the zone. So far, my operation isn’t working. I can read each frame and send a message to the console on the third frame. I’m unsure if I can move the x and y position of the zone that I’m using.
I decided to make a codepen demonstrating overlaps with animation, after your suggestions. I learned you can enable physics on zone objects, and I disable the zones physics by disabling it on the corresponding frames. Animation update really helped the situation. Thanks for the suggestions, much appreciated.