To forage in Project Zomboid, you will need to use Search Mode. To forage using Search Mode, you must first activate it. Start by pressing the magnifying glass icon on the left of your screen.
Pressing the magnifying glass will open a tab showing the investigate area box. But to enable search mode, you will need to hit the option that says enable search mode, as shown below.
Once enabled, you will then be able to forage using Search Mode in Project Zomboid by walking around in an area such as woods or woodland or urban location.
As you move around while in Search Mode, you will eventually see a white eye icon pop up over your head, as shown above.
This icon tells you when your character has found a forageable item. Alongside this icon, you will also see a small white arrow that will point you in the direction of the item.
Related: How to make and use a Rain Collector in Project Zomboid
Follow the arrow until the icon turns a solid color. When you reach a spot where the eye icon turns a solid color, move around slightly until the item is eventually revealed.
At this point, you will be able to pick up whatever it is you found. However, you should note before foraging that you will need to walk as both running and jogging will cancel Search Mode. You can also use the aim key to help find items and combine it with sneaking for an even greater boost.
Another feature of Search Mode is that certain areas will have different items you can forage. For example, woods will have more materials and plants, while urban areas may have more medicine, food, and other supplies.
For more on Project Zomboid, we have you covered.