I am currently trying to make a whip for my 2D top down game. This whip would be able to extend in all direction and damage enemies on impact. Only problem is, I have absolutely no idea how to make it. I’ll probably need whip animations to show it extending and all, which I can probably get done. But I don’t have a clue as to how I would implement it in-game with code, hitboxes and mouse movement. The whip should be able to follow the mouse (aim/look in the direction of the mouse) and whip (extend) to where the mouse is clicked. I really need this done, so if anyone can provide a detailed explanation to help me or even hop on a call with me on discord and work with me on this… I’d really appreciate it.
Discord username: opticaledits
Adding with #: OpticalEdits#0904
Love your concept sketches. Good good gamedev stuff!
That’s a good question. It almost feels like it should only deal damage when it “snaps.”
The only whips I can think of were in older games like early Castlevania, where they were just sort of like a long J that came out and made a “snap” noise when they touched something and came back.
I guess you want to start with a design on what interactions you want, break down what you mean by;
Like build a graph of states:
- user standing
- user winding up
- whip extending
- whip snapping
- whip coming back
And identify how you want all the controls (mouse movement and clicking) to work to move between those states… like do you click and hold and the player rears back with the whip over his head and then you can aim around and when you let go it goes flying out, then click again to snap it??
Plus you have to decide how realistic you wanna get on the physics / appearance.
Well the way I want to make a whip is basically, when the user presses left-click on the mouse, the whip does the snap animation and the end of the whip deals damage to a small radius where the mouse was clicked. The whip would have an animation similar to this:
The very end of the whip would deal damage and I’m thinking I could add a small hitbox there and write code to only deal damage to the enemy if the are hit by the hitbox. I don’t really need the whip animation to look too realistic, just need it to look cool like in the gif above.
That’s what my original plan was, but I was unsure if it was the right way to go. Thanks for confirming that. I just don’t know how to write the code to make the whip actually whip (do the animation) in the direction the mouse is clicked. Any ideas?
Animate one sprite sequence, even if it is just a few frames, and then get EVERYTHING else working.
You might work with a near, medium and far animation separately for the range of the target.
But whatever you do, start with one particular length and see how it goes. That might be all you need.
Get a pure attack-right working 100% correctly.
Then rotate it to face around whichever direction you click.
After that, iterate towards making it look better and better, as it may look weird snapping north / south
Alright I think I understand how to go about doing it now. Thanks a lot for your help. I’ll start working on it and update you here if I need any more help.