Hey ppl!
I'm new to DGDK, I'm learning right now and I'm just trying to create a 3rd Person Game...
I have a weird problem
I set the camera to follow this way:
dbSetCameraToFollow(dbObjectPositionX(111), dbObjectPositionY(111)+2.0f, dbObjectPositionZ(111), dbWrapValue(dbObjectAngleY(111))+180.0f, g_fCamDistance, dbWrapValue(dbObjectPositionY(111)), 10.0f, false);
Everything work's fine until the player moves down... Suddenly the camera gets from 2.0f Y position to 350.0f or something
Here's the complete code:
#include "DarkGDK.h"
#include <math.h>
float g_fSpeed = 0.1f;
float g_fTurn = 0.03f;
float OldCamAngleY;
float OldCamAngleX;
float CameraAngleY;
float CameraAngleX;
float g_fCamDistance = 5.0f;
float g_fCamAngle = 10.0f;
float posX;
float posY;
float posZ;
void userInput ();
void printInfos ();
void DarkGDK ()
{
dbLoadObject("Colonel-X.X",111);
dbSetDir ( "media\\" );
dbAutoCamOff ();
dbSyncOn ();
dbSyncRate (60);
//dbBackdropOff ();
dbSetCameraRange (0.05f,30000);
dbLoadBSP ("ikzdm1.pk3","ikzdm1.bsp");
//dbSetBSPCameraCollision(1,0,0.75,0);
dbScaleObject(111, 1.5f, 1.5f, 1.5f);
dbPositionObject(111, 0.0f, 1.0f, 0.0f);
dbRotateObject(111,0,270,0);
dbSetBSPObjectCollision(2,111,0.1,0);
while (LoopGDK())
{
posX = dbObjectPositionX(111);
posY = dbObjectPositionY(111);
posZ = dbObjectPositionZ(111);
dbPositionObject(111,posX,posY-0.1f,posZ);
//dbPositionCamera(posX,posY+2.0f,posZ);
printInfos();
userInput ();
dbSync ();
}
}
void userInput ()
{
//dbSetCameraToObjectOrientation(111);
if (dbUpKey())
{
dbLoopObject(111, 300, 318);
dbMoveObject(111,-0.1f);
}
else if (dbDownKey())
{
dbLoopObject(111, 300, 318);
dbMoveObject(111,0.1f);
}
else
{
dbLoopObject(111, 1, 1);
}
if (dbLeftKey())
{
dbYRotateObject(111,dbObjectAngleY(111) - 1.5f);
}
if (dbRightKey())
{
dbYRotateObject(111,dbObjectAngleY(111) + 1.5f);
}
if(dbSpaceKey())
{
dbPositionObject(111, dbObjectPositionX(111), dbObjectPositionY(111)+1.0f, dbObjectPositionZ(111));
}
//dbPositionCamera( dbObjectPositionX(111), dbObjectPositionY(111)+1.0f, (dbObjectPositionZ(111)-1.8f));
dbSetCameraToFollow(dbObjectPositionX(111), dbObjectPositionY(111)+2.0f, dbObjectPositionZ(111),
dbWrapValue(dbObjectAngleY(111))+180.0f, g_fCamDistance, dbWrapValue(dbObjectPositionY(111)), 10.0f, false);
}
void printInfos ()
{
char szFPS [256] = "";
strcpy (szFPS,"Fps = ");
strcat (szFPS,dbStr(dbScreenFPS()));
dbText (dbScreenWidth() - 20 - dbTextWidth(szFPS),dbScreenHeight() - 40,szFPS);
char szPosX [256] = "";
strcpy (szPosX,"PosX = ");
strcat (szPosX,dbStr(dbCameraPositionX()));
dbText (10,10,szPosX);
char szPosY [256] = "";
strcpy (szPosY,"PosY = ");
strcat (szPosY,dbStr(dbCameraPositionY()));
dbText (10,30,szPosY);
char szPosZ [256] = "";
strcpy (szPosZ,"PosZ = ");
strcat (szPosZ,dbStr(dbCameraPositionZ()));
dbText (10,50,szPosZ);
}
Please help...
Thanks!