Hello! I am trying to do something very simple. I am making a top-down game where the player has a whip to kill enemies.
I want the whip to expand until it reaches the mouse, interact with an enemy, and shrink down to regular size.
Using the PointAndOrbit Extension, I have it around the player pointing to the mouse, so the only thing I’m missing is that it touches the mouse and goes back. Using math I can calculate the distance of pixels it needs to expand, but the issue is that since it expands both ways, not only do you need double to reach the target, but it goes in both directions.
I have tried using rotations and other extensions, but I end up missing the distance or the angle. If you have any ideas, please comment!
I’ve played with a similar concept. Most recently with a frog’s tongue. I also tried it with a grappling hook like in Zelda.
The key is to put it in the center of a start and end position. You can use a tiled or a panel sprite. The benefit of a panel sprite is you can have fixed ends and just lengthen the center part.
I used a tween and calculated the time nased on distance to keep the speed consistent whether it was short or long.