Added collision detection with terrain.