In this paper we present a method of generating an optimal controller for impulsive hybrid mechanical systems, such as those undergoing impact. Our goal is for the optimization procedure to incorporate the dynamics of the impact rather than treating it as a disturbance. To this purpose we make use of a projection operator - obtained from a projected version of Hamilton's principle - to build an equivalent switched system that is expressed throughout the state space, including the infeasible regions. This eliminates the discontinuous jumps in velocity of impulsive systems. The approach allows us to apply continuous-time optimization techniques intended for normed function spaces (rather than generalized function spaces) and concretely produces an optimal controller hybrid mechanical system. We developed a Python package that applies the required transformation to simple mechanical systems undergoing impact and implements optimal control methods. Finally, we apply the projection-based technique described to a simple bouncing ball example.