We provide a multiplicity result for critical points of a functional defined on the product of a compact manifold without boundary and a convex set, by assuming, for example, an avoiding rays condition at the boundary of that set. We then extend this result to an infinite-dimensional setting which well applies to the search of periodic solutions of pendulum-like equations.