Updating collisions makes huge fps drops... ?

First I would like to apologize for my bad English and noobness level of over 9000. ::slight_smile:

I’m making a little 3d game with lwjgl but I came into a huge issue. I have a grid made out of squares and I am checking collisions for all of them. I am using the “ground square’s” collisions to get some kind of path finding and stuff like that… This appears to be making my fps drop from my 60(that is the fps limit I have) to 25 - 30. When I disable all of the squares’ collision checking the game runs just perfectly smooth. I am getting all the squares that are next to the object’s current one, so I can make the object not to be able to go to the square if I have set it to be impassable.

Here is the code I have to get the squares’ collisions:

public void update(){
		
		// c means in game character...
    // Yes... I know I should have used arrays here on "nextGroundPieces" xDd
		for(int i = 0; i < GameBoard.c.length; i++){ 
			
			
			//  ! ! ! gpi = Ground piece array index number ! ! !
			for(int gpi = 0; gpi < World.map.gp.length; gpi++){
				if(World.map.gp[gpi].getCollision(GameBoard.c[i].getX(), 0.0f/* This is because currently collision is done using only X and Z */ , GameBoard.c[i].getZ())){
					GameBoard.c[i].setCurrentGroundPiece(gpi);
				}
				
				if(Map.gp[gpi].getCollision(GameBoard.c[i].getX(), 0.0f/* This is because currently collision is done using only X and Z */ , GameBoard.c[i].getZ() + 1.25f)){
					GameBoard.c[i].setNextGroundPiece1(gpi);
				}
				
				if(Map.gp[gpi].getCollision(GameBoard.c[i].getX(), 0.0f/* This is because currently collision is done using only X and Z */ , GameBoard.c[i].getZ() - 1.25f)){
					GameBoard.c[i].setNextGroundPiece2(gpi);
				}
				
				if(Map.gp[gpi].getCollision(GameBoard.c[i].getX() + 1.25f, 0.0f/* This is because currently collision is done using only X and Z */ , GameBoard.c[i].getZ())){
					GameBoard.c[i].setNextGroundPiece3(gpi);
				}
				
				if(Map.gp[gpi].getCollision(GameBoard.c[i].getX() - 1.25f , 0.0f/* This is because currently collision is done using only X and Z */ , GameBoard.c[i].getZ())){
					GameBoard.c[i].setNextGroundPiece4(gpi);
				}
				
				
				
				if(Map.gp[gpi].getCollision(GameBoard.c[i].getX() + 1.25f , 0.0f/* This is because currently collision is done using only X and Z */ , GameBoard.c[i].getZ() + 1.25f)){
					GameBoard.c[i].setNextGroundPiece5(gpi);
				}
				
				if(Map.gp[gpi].getCollision(GameBoard.c[i].getX() - 1.25f, 0.0f/* This is because currently collision is done using only X and Z */ , GameBoard.c[i].getZ() - 1.25f)){
					GameBoard.c[i].setNextGroundPiece6(gpi);
				}
				
				if(Map.gp[gpi].getCollision(GameBoard.c[i].getX() + 1.25f, 0.0f/* This is because currently collision is done using only X and Z */ , GameBoard.c[i].getZ() - 1.25f)){
					GameBoard.c[i].setNextGroundPiece7(gpi);
				}
				
				if(Map.gp[gpi].getCollision(GameBoard.c[i].getX() - 1.25f , 0.0f/* This is because currently collision is done using only X and Z */ , GameBoard.c[i].getZ() + 1.25f)){
					GameBoard.c[i].setNextGroundPiece8(gpi);
				}
			}
				GameBoard.c[i].setPos(GameBoard.c[i].getX(), Map.gp[GameBoard.c[i].getCurrentGroundPiece()].getY(), GameBoard.c[i].getZ());
		}
		
	}

And yes I know this is made absolutely horribly but it would get the job done if it wouldn’t make the fps drop so badly. :persecutioncomplex:

Please help me. What can I do? :’(