# 3D Collision problems

i have 2 3D cubes one which is moving and the other is stands in the Map.
But if the Camera cube is touching the other cube, the cube gets stuck in some positions

Collision Class:

``````	public static boolean Checkfront(float camx, float camy, float camz)
{
float x = 0.0f;
float y = 0.0f;
float z = 0.0f;

if (x - 1.03 < camx && x + 1 > camx || x == camx){
if (y < camy && y + 1 > camy || y == camy){
if (z < camz && z + 1 > camz || z == camz){
return true;
}else{
return false;
}
}else{
return false;
}
}else{
return false;
}
}

public static boolean Checkleft (float camx, float camy, float camz)
{
float x = 0.0f;
float y = 0.0f;
float z = 0.0f;

if (x - 1.03 < camx && x > camx || x - 1 == camx){
if (y < camy && y + 1 > camy || y == camy){
if (z - 1 < camz && z + 1 > camz || z == camz){
return true;
}else{
return false;
}
}else{
return false;
}
}else{
return false;
}
}

public static boolean Checkback (float camx, float camy, float camz)
{
float x = 0.0f;
float y = 0.0f;
float z = 0.0f;

if (x - 1.03  < camx && x + 1 > camx || x == camx){
if (y < camy && y + 1 > camy || y == camy){
if (z - 1 < camz && z + 1 > camz || z == camz){
return true;
}else{
return false;
}
}else{
return false;
}
}else{
return false;
}
}

public static boolean Checkright (float camx, float camy, float camz)
{
float x = 0.0f;
float y = 0.0f;
float z = 0.0f;

if (x + 1.03 > camx || x == camx){
if (y < camy && y + 1 > camy || y == camy){
if (z - 1.03 < camz && z + 1 > camz || z == camz){
return true;
}else{
return false;
}
}else{
return false;
}
}else{
return false;
}
}
``````

Move Class:

``````public static void PlayerControle()
{
if(Keyboard.isKeyDown(Keyboard.KEY_W) && physic.Checkforne(x, y, z) == false){
z -= speed * Math.sin(Math.toRadians(ry +90 * 1));
x -= speed * Math.cos(Math.toRadians(ry -90 * 1));
Player1Cam.posz = -z - 5;
}
if(Keyboard.isKeyDown(Keyboard.KEY_S) && physic.Checkhinten(x, y, z) == false){
z += speed * Math.sin(Math.toRadians(ry +90 * 1));
x += speed * Math.cos(Math.toRadians(ry -90 * 1));
Player1Cam.posz = -z - 5;
}
if(Keyboard.isKeyDown(Keyboard.KEY_A) && physic.Checkrechts(x,y,z) == false){
z -= speed * Math.sin(Math.toRadians(ry +90 * 0));
x -= speed * Math.cos(Math.toRadians(ry -90 * 0));
Player1Cam.posx = -x - 0.5f;
}
if(Keyboard.isKeyDown(Keyboard.KEY_D) && physic.Checkleft(x,y,z) == false){
z += speed * Math.sin(Math.toRadians(ry +90 * 0));
x += speed * Math.cos(Math.toRadians(ry -90 * 0));
Player1Cam.posx = -x - 0.5f;
}

}
``````