Baseball VR

Knock the ball out of the park in an immersive, virtual reality experience of American baseball. Challenge your home run hitting skills, best your friend in a local pitching battle, or play a game of Moon Ball!
May 2018 — HTC Vive — Unity
Baseball VR puts you on the pitch, cracking bats and hitting home runs past the fences in the American baseball diamond. Practice your batting against different types of pitches you choose, and after you're ready, see if you can make it to the big leagues in the Home Run Derby mode. Being my largest and most recent undertaking, I worked on this project as a programmer, designer, and producer for approximately 12 months.
Features
Calulated curves and trajectories of different pitch types
Even though the main action in Baseball VR is swinging your bat at a ball, what is closely connected to that is the way the ball moves, curves, and flows down towards the strike zone. This aspect of the game had to feel fair, learnable, and interesting enough to keep players enticed with pitches that were different, dynamic, and unexpected each time. And so, we decided it best to implement various types of pitches, well known in the real world of baseball. These included the Fastball, Curveball, Slider, and Screwball. The way these pitches are differentiated are based upon their release, curvature, and overall speed as they move over the plate. I implemented this feature by creating mathematical curves using Sin and Cosin equations, tweaking their amplitude, frequency, and period to match the behavior of the pitch, and moving the ball along this curve over time while factoring in gravity and the constraints of the strike zone. Once these features were all implemented, worked together, and were balanced, the system worked surprisingly well and even under extreme conditions, as you can see on the next feature. Here is the script: Pitch Animator
implemented 'Pitch from field' mode && designed 'moon ball'
Once we had the initial pitch curvatures working from the mound to home plate (roughly 60 ft.), I wanted to test the limits of the system and see if would break under extreme conditions. So, I moved the pitcher far away from the mound, in the middle of the outfield, and surprisingly, it worked really well. Since the pitch was calculated mathematically, using quadratic equations, all we had to do was feed the starting position of the pitch, the target speed, and the type of pitch, and we could calculate the direction and angle of the pitch for it to land where it wanted in the strike zone. We called this script PitchZone
One impressive aspect of this was that the initial pitch position could even be moved vertically up into the air, and still worked. Once I tried this, I was very pleased with the result and wanted to be a little playful, so I thought it a great idea to just turn the gravity down to a very low setting, and reskin the aesthetics of the skybox, baseball, and bat. Knocking asteroids out into space in zero-g was a blast. And so, once I added in the game aspect of having to stop the asteroids from destroying the earth (getting past home plate), I named this mode 'Moon Ball'. From the mundanities and sincerities of a competitive sport, to being surprised by a playful and creative intergalactic standoff, a lot of players enjoyed it.
overcame creative challenge of
two-player vr mode
(Baseball VR does not normally have this orange box in the game, but as an unfortunate necessity, it is in the video capture)
We also implemented a Two-player mode called 'Double Play'. We wanted to do a two-player mode, not only because it was an interesting challenge, but also because our boss set it upon us that he wanted multiple people to be able to play these games together, even if they were in VR.
Since VR only allows one person to control and see the game, we had to bring in another screen, the monitor of the computer the VR system was hooked up to. The way we achieved this was technically difficult. We duplicated the original roomscale-VR player game object, and removed all the functional objects besides one of the motion controllers (the pitching hand). Then, we would have the player who was pitching first stand in front of the TV, which was casting a virtual camera view of the pitcher's mound, and calibrate their real-world position to the screen. That player could then choose a pitch type, aim with the TV screen space, and throw it by using the motion of their controller. And then, with the speed, direction, and type of the pitch thrown, we could calculate the pitch parameters and make sure it got inside the strike zone. We did this by creating a 1:1 ratio of the box-shaped screen space of the TV, and mapping that to the box-shaped strike zone in the game. So, if you released your pitch at the top-left corner of the screen, the pitch would go through the point at that strike zone corner in the game.
Players had fun with this mode, especially being able to play against their friends, and take turns seeing what the game looked like from inside the headset and spectating on the TV from the outside.