I'm trying to have a 3d model move forward based on the position he is facing. So far, I have;
if (checkL() ) //If Left button is pushed
{
dbMoveObjectLeft(Character,-PlayerSpeed); //moves object left
iPlayerPosition = LEFT; //change the player position to LEFT
dbMoveCameraLeft(Camera, PlayerSpeed);//moves the camera
}
else if (checkR() )//If Right Button is pushed
{
dbMoveObjectRight(Character,-PlayerSpeed);//moves object right
iPlayerPosition = RIGHT;//changes player position to RIGHT
dbMoveCameraRight(Camera, PlayerSpeed);//moves the camera
}
else if (checkfwd() )//If Forward Button is Pushed
{
dbMoveObject(Character,-PlayerSpeed);//moves object forward
iPlayerPosition = FORWARD;//changes player position to FORWARD
dbMoveCamera(Camera,PlayerSpeed);//moves the camera
}
else if (checkback() )//If Back Button is pushed
{
dbMoveObject(Character,PlayerSpeed);//moves object back
iPlayerPosition = BACK;//changes player position to BACK
dbMoveCamera(Camera,-PlayerSpeed);//moves the camera
}
Now this works but I also want to integrate camera controls using the mouse:
if (checkMouse())
{
fCameraAngleY = dbWrapValue ( fCameraAngleY + dbMouseMoveX()* 0.4f );//calculates the angle to move based on the distance the mouse moved
dbYRotateObject(Character,fCameraAngleY+180);//rotates object at that angle
dbYRotateCamera (fCameraAngleY );//rotates camera at that same angle
angle = fCameraAngleY;
When I play the game, when you push the button to go forward, he moves forward and a bit to the right for some reason. I've tried hard to fix this but to no avail. Any tips??