When is potential energy produced?

If I'm not mistaken. The formula for Potential Energy in Physics is

PE = mgy wherein PE = Potential Energy, m = mass, g = acceleration due to gravity, and y = height.

As you will be able to observe potential energy will be produced when the object has a height. Like a person on top of a building, a tennis ball in the air, etc.

What if the object has no height?

- Well, it's simple. When we let y = 0, and multiply it to g and m, PE = 0. Therefore there will be no potential energy produced.