Hey
Sorry for all the questions. But how do I keep a object on the floor? I already have camera and object collision so my object won't walk trough walls. Yet he still hovers.
Main.cpp
#include "DarkGDK.h"
#include "Player.h"
#include "string.h"
Player *Knight = new Player;
void UserControl();
void DarkGDK()
{
dbSyncOn();
dbSyncRate(60);
dbLoadObject("H-Knight-Move.x", 1);
dbLoadBSP("ikzdm1.pk3", "ikzdm1.BSP");
dbSetCameraRange (0.05f, 30000);
dbRotateObject(1, 0, 180, 0);
dbSetBSPCameraCollision(1, 0, 0.75, 0);
dbSetBSPObjectCollision(1, 1, 0.75, 0);
while(LoopGDK( ))
{
UserControl();
dbPositionCamera(*Knight->x, *Knight->y + 2, *Knight->z - 5);
dbSync();
}
delete Knight;
}
void UserControl()
{
if (dbKeyState(17) == 1)
{
if (dbObjectPlaying(1) == 0)
{
dbPlayObject(1, 1, 20);
}
dbMoveObject(1, -0.1);
}
if (dbKeyState(31) == 1)
{
if (dbObjectPlaying(1) == 0)
{
dbPlayObject(1, 1, 20);
}
dbMoveObject(1, 0.05);
}
if (dbKeyState(30) == 1)
{
*Knight->fangle -= 5;
dbRotateObject(1, 0, *Knight->fangle, 0);
}
if (dbKeyState(32) == 1)
{
*Knight->fangle += 5;
dbRotateObject(1, 0, *Knight->fangle, 0);
}
*Knight->x = dbObjectPositionX(1);
*Knight->y = dbObjectPositionY(1);
*Knight->z = dbObjectPositionZ(1);
}
Player.h
class Player
{
public:
Player();
~Player();
float *x;
float *y;
float *z;
float *fangle;
private:
int health;
};
Player::Player()
{
x = new float(0);
y = new float(0);
z = new float(0);
fangle = new float(180);
}
Player::~Player()
{
delete x;
delete y;
delete z;
delete fangle;
}