Remember Michael C.? He’s teamed up with instructor Dilan as part of Game-U’s New Jersey Accelerate program. Michael builds game after game as he works towards mastering the skills associated with game development. His latest project? Ping pong in virtual reality (VR)!
At first, Michael and Dilan began setting up the game environment as if for a console-based project, where the gamer controls the ping pong paddle via keypresses and receives visual input from the computer screen, but this is the future, isn’t it? A ping pong video game can go so much further than the screen! Michael’s already familiar with VR thanks to his time with one of Game-U’s Oculus lenses, so he and Dilan began adapting his project into an immersive VR experience. Using Unity, the professional gaming engine, Michael added a table and a wall to the game environment and gave them rigidbodies (think of rigidbodies like invisible wrappers that provide intangible objects with the digital equivalent of hardness or other physical properties, such as gravity). He also created a ball object and a ping-pong paddle. With these props in place, Michael moved on to coding the game’s interactions!
Michael first laid out the requirements to play ping pong in VR. For example, the player needs to be able to pick up and swing the paddle, the ball needs to react to the paddle as it would to a hard surface, and the game needs to be able to calculate the direction and force associated with each strike in order to animate the ball appropriately. The game also needs to know how to react when the ball flies out-of-bounds. Michael brainstormed and then programmed scripts to handle all of these circumstances, as his game video shows! When the ball bounces out of bounds, it disappears and is respawned on the table. The paddle responds to the remotes the player uses to interact with virtual objects, and it can be swung and manipulated based on the position of the player’s hand. The remotes send data about each strike to the game, which then processes that information and controls the speed and direction of the ball to mimic the real-life response of a ball struck similarly. Thanks to the rigidbodies attached to the table and wall, the ball also rebounds when it strikes either surface. VR ping pong is ready to play!
Awesome work here, Michael! We’re excited to see you take on the future and bring more games into virtual reality. Thanks for sharing. Be sure to keep us updated on your project as you continue to improve it with new features!