Greetings internet. I’m here to talk about a game that I’ve been developing slowly after work. And you’re probably here to listen to all my failures. Great! Let’s get into it.

Lots of sports have a game series - soccer has FIFA, basketball has NBA2K, even ice hockey has NHL2K. But what does volleyball have? Dead or Alive: Xtreme Beach Volleyball is the only well known volleyball game, which is like saying two pieces of bread with a pepperoni in the middle is a sandwich.

I’m trying to make a faithful simulation of indoor six-man volleyball, working title: Volleyballad. I want the player to be able to control one person on the team, while the rest are controlled by AI, with each AI having its own habits the player can pick up on.

The first important task was to figure out how to get a player to hit a ball toward a target in a parabolic arc.

The hiccup here was figuring out what I could solve for, and choosing which variables I could give as constants. Initially I tried solving for the angle of the trajectory using the maximum height, but that left too many variables unaccounted for. Eventually, I found I could pass the destination and the airtime, and solve for velocity. Beginning with the equation of projectile motion…

Expanding this equation to three components…

Solving for velocity…

And so we end up with something like this.

// C#
Vector3 CalculateVelocityForTrajectory(Vector3 pos, Vector3 dst, float t) {
        Vector3 diff = dst - pos;
        Vector3 v = diff / t;
        v.y -= Physics.gravity.y * t / 2;
        return v;
}

As of now, if a player touches the ball, the ball’s velocity is set to this value. Check it out in context below!

SET THE D