I am trying to recreate a grappling hook to use in my game.
However, I'm having trouble creating a rope that connects from point A to point B and "shrinks" until it takes the player to the new location.
I tried to follow the official example called "Hook shot" present on Construt 3 (so I managed it by creating a Tile Sprite, and modifying its Width depending on the distance the rope has to reach).
Following the example everything works perfectly, but I have a problem with coordinates.
I'll leave you a quick sketch I made to better show you my current situation:
Basically I can perfectly create my own rope, and make it reach its destination by changing its Width.
The problem is that when I go to decrease its Width to 0 (so making the player reach the hooked point), the rope moves to the right or left. probably this is due to the fact that changing the Width of the sprite, the image changes position.
Does anyone know how I can solve this problem? I would like to make it so that once hooked the point to be reached, the rope shrinks until it has a length equal to 0, but maintaining its coordinates that were used to connect the point A and B of the hook. In my current situation, the hook is executed correctly, but the player is dragged to a position that is not precisely where the hook hit.
Develop games in your browser. Powerful, performant & highly capable.
It's difficult to tell without the project file. What object are you using for the rope? If it's a sprite, check origin point position in it.