Echolocating bats use echolocation to navigate and forage, often in total darkness. They generally emerge from their roosts in caves, attics, or trees at dusk and hunt for insects into the night. Using echolocation, bats can determine how far away an object is, the object's size, shape and density, and the direction (if any) that an object is moving. Their use of echolocation allows them to occupy a niche where there are often many insects (that come out at night since there are fewer predators then), less competition for food, and fewer species that may prey on the bats themselves.