Uh not really, here you can test out this code and see that because of that I can't use forces.
#include "DarkGDK.h"
#include "DarkPhysics.h"
#include "DarkAI.h"
#include "DarkLights.h"
#include "ShaderData.h"
#pragma comment ( lib, "DarkPhysics.lib" )
#pragma comment ( lib, "DarkAI.lib" )
#pragma comment ( lib, "DarkLights.lib" )
#pragma comment ( lib, "ShaderData.lib" )
void DarkGDK ( void ) {
//Settings
dbSyncOn();
dbPhyStart();
dbPhySetGravity(0,-200,0);
dbSyncRate(60);
dbBackdropOn();
dbPositionCamera(0,0,-10,30);
//Player
dbMakeObjectCube(1,40);
dbPositionObject(1,0,60,0);
//Other Objects
dbMakeObjectBox(2,200,1,200);
dbColorObject(2,RGB(126,235,21));
dbMakeObjectCube(3,80);
dbColorObject(3,RGB(255,0,0));
dbPositionObject(3,0,0,30);
dbMakeObjectSphere(4,20);
dbColorObject(4,RGB(255,0,0));
dbPositionObject(4,0,0,-50);
dbMakeObjectBox(5,50,1,20);
dbRotateObject(5,0,0,45);
dbPositionObject(5,-55,30,0);
//Setting up physics
dbPhyMakeRigidBodyDynamicBox(1);
dbPhyMakeRigidBodyStaticMesh(2);
dbPhyMakeRigidBodyStaticMesh(3);
dbPhyMakeRigidBodyStaticMesh(4);
dbPhyMakeRigidBodyStaticMesh(5);
//Other
dbPhySetRigidBodyMassOffsetGlobal(1,0,10,0);
//Camera
dbRotateCamera(0,0,0,0);
//Loop
while( LoopGDK ( ) ) {
//Declare player position as x,y,z
float x = dbObjectPositionX(1);
float y = dbObjectPositionY(1);
float z = dbObjectPositionZ(1);
//Raycast
dbPhyRayCastAllShapes(x,y,z,0,-1,0);
float coly = dbPhyGetRayCastDistance();
//Movement
//Upkey
if (dbKeyState(200) == 1) {
dbPhyAddRigidBodyForce(1,0,0,3,0);
}
//Downkey
if (dbKeyState(208) == 1) {
dbPhyAddRigidBodyForce(1,0,0,-3,0);
}
//Rightkey
if (dbKeyState(205) == 1) {
dbPhyAddRigidBodyForce(1,3,0,0,0);
}
//Leftkey
if (dbKeyState(203) == 1) {
dbPhyAddRigidBodyForce(1,-3,0,3,0);
}
//Jumping
//Spacebar
if (dbKeyState(57)) {
if ((coly > 10) && (coly < 25))
{
dbPhyAddRigidBodyForce(1,0,50,0,2);
}
}
//Position camera to player
dbPositionCamera(0,x,y,z-100);
dbShowObject(2);
//Display x,y,z
dbInk(RGB(250,0,160),RGB(250,0,160));
dbText(0,0,dbStr((int)x));
dbText(0,10,dbStr((int)y));
dbText(0,20,dbStr((int)z));
dbText(0,30,dbStr((int)coly));
//Update Screen and Physics
dbPhyUpdate();
dbSync();
}
}
Arrow keys to move, spacebar to jump.
I want coke, not Pepsi!