DEV Community

Cover image for Scoping and Lerp
Jesús Pineda
Jesús Pineda

Posted on

Scoping and Lerp

Hellu, and welcome to my third week at A Wargame Without Compromise (WWC)! 👾

For this sprint, our primary goal was to deliver our first playable demo. It was a challenging objective; while we had all the individual pieces built, the real test was connecting them. Predictably, we ran into some complications.

Capacity was our first hurdle. We should have limited our sprint scope, taking into account that half the team had demanding external work commitments over the Valentine's Day weekend. Furthermore, we experienced some workflow disconnects. We were developing individual features, but the centralising architecture, specifically the State Machine and Game Manager, was not ready yet.

We expected the State Machine to be finished earlier in the sprint to allow for seamless integration. Sadly, we underestimated the scope of this task because the team wanted to ensure the system was robust. This delay is not the end of the world; it is a common pitfall in new projects when integrating systems with which the team has limited prior experience. We overcame this bottleneck by having a discussion to refine the State Machine's requirements and doing some knowledge transfer. The key takeaway from this sprint is the necessity of better refinement and realistic capacity planning before a sprint starts.

In addition to supporting the team's core goals, my specific tasks for this sprint included:

  • Refining the Rewind Ability: Resetting the rewind points after an action other than moving was triggered.
  • Smoothing Terrain Under Buildings: Modifying the flat terrain around newly placed buildings to look more natural.
  • Terrain Deformation: Creating visual craters in the mesh upon collision.

Rewind Ability Refining
This was straightforward to implement. With the Event Handler already in place, I simply listened for the shooting event and cleared both the rewind and fast-forward stacks when it triggered.

Smoothing the Terrain
To tackle terrain smoothing, I had to map out the math on paper first. Following a discussion with our tutor about the concept of Lerping (Linear Interpolation), the area around a building, I researched distance calculations. I found an excellent resource by Quilez (2019) detailing mathematical formulas for shapes and point distances. This helped me understand how to calculate the distance from a given point and Lerp the altitude based on that distance, the building's base altitude, and the current point's altitude. I iterated through the gridMap[][] area (adding a margin) and discarded the strictly occupied points using the occupiedMap[][] so the terrain directly underneath the building wouldn't be altered. This is the result:

Terrain Deformation
Initially, I thought deforming the mesh would be highly complex because I wasn't sure how to pinpoint the exact collision coordinates. It turned out to be quite manageable. Unity’s OnCollisionEnter method provides a Collision object containing the contact points. Using that precise point, I looped through the surrounding vertices matrix of the mesh, calculating the Pythagorean distance to ensure the crater was circular rather than box-shaped, and applied a Lerp to deform the area.

Having finished the task ahead of schedule, I added some particle effects to make the crater visually appealing. This was a great opportunity for me to step outside my pure-code comfort zone and learn something new about VFX and game feel. This is the result:

Action Plan for Next Sprint
Our goal of a fully playable demo remains. To achieve this, my concrete action plan is to step back from terrain generation features and dedicate my time to stabilising the gameplay and codebase. I will assist in fully integrating the State Machine with the rest of the game's mechanics.

My teammates have developed some fantastic systems this week, such as piercing shooting mechanics and a UI system to track unit status. Finally, I want to give my kudos to Josh this week! As a leader, he has planned effectively around our delays to ensure the best possible outcome for the team.

Thank you so much if you got this far!

See you next week for another update! 🛼🤟🏽👻

References:

Top comments (0)