Calling second pawn from player controller

I’m struggling with a problem from an architectural standpoint. I’m working a classic gameplay element, the ball and paddle.

In MyPlayerController.h/.cpp I map my inputs to functions, all good. The paddle itself is the default pawn, so the controller can simply get the attached pawn and call the pawn’s move function. I’ve got the basics down, I’m struggling with a clean way to map the launch ball button to the ball.

Previously I did this the level blueprint with a delegate. It was messy so now I want to do things a bit nicer and cleaner. Now I can declare the delegate in the player controller, but I need instances to bind right? That leaves me in the same bind as using a level blueprint.

How should this be approached from a design standpoint using C++? One would think there’s a way set this up more abstractly than binding specific instances in a level. I should be able to, in one place, tell the game that whenever the player presses the specified button, to launch the ball pawn.

I would recommend moving things like that into the game mode,

the game mode is responsible for spawning or finding the ball at game start and when the player presses the launch button it calls a function on the game mode which knows

  • which object the ball is
  • if it’s already launched
  • how to trigger the launch

This is more or less what I ended up doing. I had the player controller spawn a ball, so it can keep the reference and invoke the needed functions on it.