I’m implementing a grappling hook into my game. I want it to keep its length constant once hooked, therefore creating a circular motion around the hook point. Here’s an awesome high-resolution scheme:
http://img405.imageshack.us/img405/231/esquemaj.png
To keep things simple, I decided to keep with linear motion calc instead of switching to a circular reference system when hooked. My approach to create the circular motion is to get the player speed (yellow in the scheme) and find its orthogonal projection (pink) to the hook vector (blue/green). Then I reverse the orthogonal projection and add it to the player speed, nullifying any speed parallel to the hook vector, so that only orthogonal movement to it is possible, effectively creating a circular motion.
It seems to work, but when I’m hooked, for some reason the hook gets slowly larger, like one pixel per second or so. What could be the cause for that? Maybe it’s a precision problem? I doubt so, I’m using doubles, and one pixel per second is like A LOT of precision loss.
EDIT: I got an answer in other forum where I asked the same question. The problem is that I’m taking the tangential velocity at the tangential point. Therefore the player moves away from the circle as the only point the tangent is on the
circle is the one where the player is currently at. Okay, I got the problem, but I can’t come with a solution!