Showcasing a VR game I was contracted to work on. I was the only developer on this project and worked on the programming, gameplay design and audio for the game. I also handled the technical art side of the project doing the lighting and getting the grass/crowd stuff working, along with all the cinematic camera stuff.
Andrae Harrison created the stadium assets for the game. Major thanks go out to him for being patient iterating over the stadium designs with me to get it all looking okay in-engine on such a short timeline.
It was created for a couple of minor league baseball teams and sent to them with all the hardware on-site to be setup. The game was developed over about a month and a half in Unity for the Vive.
It uses a physical baseball bat with a vive tracker attached to the handle. The bat in-game and in reality matched 1:1 in size, which gave the interactions a great feel.Pitcher Trajectory Examples
Above are some examples of the pitcher's throw trajectory in debug mode. I can set a target point anywhere around him and as long as his pitch speed is high enough, he'll throw it exactly to that point. If his pitch speed is too low he'll aim at a 45 degree angle and throw as far as he can.Bat Collision
Similar trajectory math is done for ball/bat collisions. I really wanted to aim for stable hit responses with this game, which is extra challenging for VR collisions. I only rely on Unity's physics to notify me when a collision occurs, everything else is manually calculated so that I have a lot of control over hit responses.Bat Collision Continued
The ball/bat collision response actually might be more complicated than it might look. There are a lot of details that went into making it all feel good. There's a bat sweet spot curve, which improves hits the closer you are to the "sweet spot" of the bat.
There are also quite a few checks in place to ensure that when you swing the bat hard and fast, you usually get a good hit. Bat speed increases the collider size, compensating for the Vive tracker moving fast and data being less reliable.
There's a speed correlation value that tries to best estimate the bat's real movement speed given the tracker data (because remember you're swinging a real baseball bat with a vive tracker attached). This check really helped me get consistent results and combat the "wii waggle" issue of being able to fake the game out and still get good hits. You really did need to swing the bat hard on higher difficulties. Lower difficulties still auto-assisted a lot so it could still be fun for kids!
Also difficulty modifiers auto-correct trajectories to align more with perfect 45 degree angle hits. It's sorta like auto-aim but for swinging VR bats!