I’ll answer this in 2 parts. For the “directly” part, plants need energy from sunlight to grow. Even we benefit from the sun because it gives us Vitamin D. Now for the “indirectly” part, herbavoirs get their energy from the sun because they eat plants that have energy which came from the sun which also goes back to the herbavoirs.