The question I have about this is more geared toward the math... as I have not been able to nail down the correct formula for rotating the turret of my tank.
First, I DO have rotation working across an authoritative server/client configuration so that is not the problem I am having. The problem I am having, is the point at which the calculates the rotation from.
The player can move using the standard WASD and it is top down. The player uses the mouse to "Aim" the turret of the tank(no rotation speed, it simply snaps to place) and it should point toward the mouse location based on the mouse position on the screen, and I think that is where I am running in to problems.
I guess lets just post the code instead of me rambling.
As you can see there are a lot of commented out lines, as I have been trying everything. And what is happening is the "point" at which it calculates the rotation is down and to the left(screen wise) from the center(where the player is).
I assume it is because the server "screen" sees something different. Any help on this is appreciated.
EDIT: I don't know that it makes a difference, but the server is running in Batchmode. It might because as i recall before we started running it like that, it worked ok.
If your problem concerns only with
then you can apply the following Wiki script to your turret:
answered Dec 29, 2010 at 03:52 AM
It looks like the problem is that the mouse position is in screen coordinates, while you game is running in "world" coordinates. You have to convert the mouse position into world coordinates before you do anything with them.
answered Feb 22, 2011 at 07:28 AM