UPDATE: I worked out what my whole problem was. It wasn't that my code was incorrect. It was that my sprite and my camera were offset, but my mouse was not. So no matter what I tried, it would not function how I wanted it to. The closest thing I got to getting it to work correctly before was for it to move in a 90 degree arc but not follow the mouse accurately.
Obviously now I have offset the mouse position to half the screen width and height, things work exactly how they should work.
Hopefully people who run into the same problem will see this and realise this COULD be their problem
Ok, so I have given in and decided to ask for help because I just haven't gotten anywhere with this.
I am experimenting with different general game mechanics, such as vehicle movement using keyboard and while the player is running around, they can use the mouse to aim and interact, keyboard to strafe and move forward and back.
So far, I haven't seemed to have gotten anywhere with it for many hours now, and it's doing my head in, especially since i'm pretty sure I got it working the other day when I did a quick test, but I don't remember the code I typed before I deleted it to try out keyboard movement and rotation
This link explains what I want to do.http://stackoverflow.com/questions/16381031/get-cursor-position-in-libgdx
However I don't fully understand the solution provided.
I can get the mouse coordinates just fine. That part is pretty straight forward.
But this part to me seems rather ambiguous.
Update a Vector2 that points from the current sprite position to the cursor position. This can be your Sprite's heading. You'll want to rotate the sprite's heading to match this vector.
Use Vector2.angle() to compute the angle of this vector, and set your sprite's rotation to this. (This is relative to the positive X axis,so you may need to add a constant if you want it relative to the Y axis.)
I've tried a bunch of different things, I can get the player to rotate when I move the mouse, but not with the behaviour I would like it to.
I thought that using a dot product might help, and is probably the way to do this, but I'm not entirely sure of how to use the dot product of two vectors in this case.
I know the syntax for it, just not the application for this situation.
Any help would be appreciated.
This is the result of mouse based rotation.http://www.youtube.com/v/HIydNOPrXyY?version=3&hl=en_US&start=