I have a game idea that uses a third person perspective viewpoint. Holding down the right mouse button and moving the mouse left or right causes the camera to rotate around the player character. The player steers the on-screen character with the arrow keys. My problem is this:
Regardless of the direction that the character appears to be facing (because the camera can be spun around him, as I said, resulting in the character potentially facing any direction of on screen rotation):
Pressing a directional arrow should make the character model rotate smoothly via the shortest direction until he faces in that direction before moving forward.
In other words:
Pressing the 'up' key will make the character turn to face away from the camera. If the player is already facing 'into' the screen then he will move forward.
Pressing the 'down' key will make the character turn to face the camera. If the player is already facing toward the camera then he will move forward.
Pressing the 'left' key will make the character turn to face the left of the screen. If the player is already facing toward the left of the screen then he will move forward.
Pressing the 'right' key will make the character turn to face the right of the screen. If the player is already facing toward the right of the screen then he will move forward.
Combinations of keys (for example, pressing 'up' and 'left') should, of course, cause the same type of behaviour for diagonal movement.
All of the above should work consistently regardless of the original rotation of the player model, which could be any angle depending on how the player rotates the camera.
Sorry for describing this in such minute, repetative detail, but I've asked for help with this before and people always seem to misunderstand what I'm after.
There does not appear to be any built in commands to exactly match my requirements. I gather that it has something to do with vectors, but I'm really not sure. My knowledge of mathematics sucks.
Can anyone help me with this, please?
Regardless of the direction that the character appears to be facing (because the camera can be spun around him, as I said, resulting in the character potentially facing any direction of on screen rotation):
Pressing a directional arrow should make the character model rotate smoothly via the shortest direction until he faces in that direction before moving forward.
In other words:
Pressing the 'up' key will make the character turn to face away from the camera. If the player is already facing 'into' the screen then he will move forward.
Pressing the 'down' key will make the character turn to face the camera. If the player is already facing toward the camera then he will move forward.
Pressing the 'left' key will make the character turn to face the left of the screen. If the player is already facing toward the left of the screen then he will move forward.
Pressing the 'right' key will make the character turn to face the right of the screen. If the player is already facing toward the right of the screen then he will move forward.
Combinations of keys (for example, pressing 'up' and 'left') should, of course, cause the same type of behaviour for diagonal movement.
All of the above should work consistently regardless of the original rotation of the player model, which could be any angle depending on how the player rotates the camera.
Sorry for describing this in such minute, repetative detail, but I've asked for help with this before and people always seem to misunderstand what I'm after.
There does not appear to be any built in commands to exactly match my requirements. I gather that it has something to do with vectors, but I'm really not sure. My knowledge of mathematics sucks.
Can anyone help me with this, please?