Ok, I’ve used the code from my last thread of this name to get a camera adjustment on my third person prospective camera.
However I want the camera to move around the character object in an orbit so you click the left mouse button and then move the mouse up, down, left and right to move the camera around while keeping the camera behind the character object. That way when i press up or down I can move the character forward and backward while controlling the characters direction movement via the mouse.
To do this I have gotten this code to control the camera but thus far can’t work out how to orbit the character, instead it turns on the spot in a 360 degree fashion whereas I want it the camera to move while it points at the object:
if ( MouseClick == 2 ) // Camera prespective alteration.
{
dbRotateCamera ( 0, dbCameraAngleX ( 0 ) + MouseMovY, dbCameraAngleY ( 0 ) + MouseMovX, dbCameraAngleZ ( 0 ) ) ; // Left Click Camera Mouse Move
if ( dbLeftKey ( ) ) // Turn left when the left key is pressed
{
dbMoveObjectLeft ( 1, 1 ) ;
float TPCX = dbObjectPositionX ( 1 ), TPCY = dbObjectPositionY ( 1 ), TPCZ = dbObjectPositionZ ( 1 ) ; // Gets character position
dbPositionCamera ( TPCX, TPCY, TPCZ ) ; // Reposition the camera at the characters location
dbSetCameraToObjectOrientation ( 1 ) ; // Point the camera the same way as the object
dbMoveCamera ( -40 ) ; // Moves camera backwards into a 3RD person behind the head location
float CPX = dbCameraPositionX ( ), TPCY2 = dbObjectPositionY ( 1 ), CPZ = dbCameraPositionZ ( ) ; // Gets character position
dbPositionCamera ( CPX, TPCY2+15, CPZ ) ; // Moves the camera upwards to compleat the 3D person prespective
}
if ( dbRightKey ( ) ) // Turn right when the right key is pressed
{
dbMoveObjectRight ( 1, 1 ) ;
float TPCX = dbObjectPositionX ( 1 ), TPCY = dbObjectPositionY ( 1 ), TPCZ = dbObjectPositionZ ( 1 ) ; // Gets character position
dbPositionCamera ( TPCX, TPCY, TPCZ ) ; // Reposition the camera at the characters location
dbSetCameraToObjectOrientation ( 1 ) ; // Point the camera the same way as the object
dbMoveCamera ( -40 ) ; // Moves camera backwards into a 3RD person behind the head location
float CPX = dbCameraPositionX ( ), TPCY2 = dbObjectPositionY ( 1 ), CPZ = dbCameraPositionZ ( ) ; // Gets character position
dbPositionCamera ( CPX, TPCY2+15, CPZ ) ; // Moves the camera upwards to compleat the 3D person prespective
}
if ( dbUpKey ( ) ) // Move the character forward.
{
dbMoveObject ( 1, 1 ) ;
float TPCX = dbObjectPositionX ( 1 ), TPCY = dbObjectPositionY ( 1 ), TPCZ = dbObjectPositionZ ( 1 ) ; // Gets character position
dbPositionCamera ( TPCX, TPCY, TPCZ ) ; // Reposition the camera at the characters location
dbSetCameraToObjectOrientation ( 1 ) ; // Point the camera the same way as the object
dbMoveCamera ( -40 ) ; // Moves camera backwards into a 3RD person behind the head location
float CPX = dbCameraPositionX ( ), TPCY2 = dbObjectPositionY ( 1 ), CPZ = dbCameraPositionZ ( ) ; // Gets character position
dbPositionCamera ( CPX, TPCY2+15, CPZ ) ; // Moves the camera upwards to compleat the 3D person prespective
}
if ( dbDownKey ( ) ) // Move the character back.
{
dbMoveObject ( 1, -1 ) ;
float TPCX = dbObjectPositionX ( 1 ), TPCY = dbObjectPositionY ( 1 ), TPCZ = dbObjectPositionZ ( 1 ) ; // Gets character position
dbPositionCamera ( TPCX, TPCY, TPCZ ) ; // Reposition the camera at the characters location
dbSetCameraToObjectOrientation ( 1 ) ; // Point the camera the same way as the object
dbMoveCamera ( -40 ) ; // Moves camera backwards into a 3RD person behind the head location
float CPX = dbCameraPositionX ( ), TPCY2 = dbObjectPositionY ( 1 ), CPZ = dbCameraPositionZ ( ) ; // Gets character position
dbPositionCamera ( CPX, TPCY2+15, CPZ ) ; // Moves the camera upwards to compleat the 3D person prespective
}
}