S2E15: The Problem with Parabolas, or How I Fixed my Visual Model

After several iterations, and a lot of paper math I have nailed down the core of the visual model for my game! This took a lot longer than expected, but was expected to be the most technically challenging part of this project since relatively early on. I’ll explain what happened.

My concept was to use a parabolic path for objects to move around the player to roughly model the visual movement of an object as it approaches from the horizon. It gives it a nice skewed curve, and this original idea is still sound. When I prototyped the system I naturally created the parabola in the terms I was most familiar with, and which intuitively made sense with the intended visual output: the parabola would be along the x, y axes.

I created this, and sure enough it had the intended visual effect. Applying a pleasant scaling effect was simple enough too.

Where I ran into problems was when I tried to sync this visual representation up with the internal data’s model of the game world. The game could display an object moving closer from the horizon until you stopped next to it. And the game could detect when the player was next to an object in engine. But these two did not match up. My assumption was that this would be a simple matter of tuning the visual model’s variables to match up intuitively with the engine. But what I found was even this would not account for multiple objects arrayed out along the x axis.

Objects with the same y and z coordinates, but offset along x would require very different values for these tuning variables to align with the player when their z positions were equal.

I was roughly able to set up a formula to adjust this dynamically, but it left the objects misaligned at any z value relative the player other than 0. I’m sure there is some way to create an advanced formula that could account for this as well, but trying to find it seemed like more trouble than it should be for the intended visual effect. I created another algorithm to try and accomplish this that, from inception, considered that object’s visual y position should be the same at any given internal y and z position. But I continued to run into problems, and could not wrap my head around how to easily align the objects’ visual y positions at every z position. This eventually led me to the solution.

My mistake was in how and in what order the variables were dependent on one another. Originally I calculated them in the dependent order of x -> y -> z, and was closer with the previous attempt using z -> x -> y. But this still designed the dependencies around the assumption the movement was parabolic on the x, y axis. While this is ultimately true visually, the important relationship is that y and z coincide. ┬áSo I realized I should be creating the parabolic relationship between y and z, with x derived from z. This way the only non-linear displacement for any visual axis is dependent on only z on the engine’s side.

I still have a lot of work to do on the project in general. But it is largely work I already know how to do, and will be much easier to sit down and crank out in the next couple weeks. I’ve received confirmation that my deadline for the current demo production will be the 18th of this month

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s