Core Mechanic: Troubleshooting

Testing plays a crucial role in game development, especially for interactive AR experiences like Pippo Math. Recognizing its importance, I allocated extra time in the timeline for thorough testing, allowing me to identify areas for improvement and refine both the code and gameplay. This blog explores five major challenges I encountered during testing and how I iteratively improved the game through dedicated adjustments.

Problem 1: Inconsistent Bubble Spacing

Issue:

The first problem was the bubbles were unevenly spaced around the player. Sometimes, bubbles spawned too close together, while other times, they spread too far apart. This inconsistency made the game feel unpredictable and unpolished.

Cause:

The original code randomized the angle and distance for each bubble. While randomness added variety, it sacrificed clarity, especially for kids learning math. I realized the game needed consistent spacing while keeping the answers randomized.

Solution:

Instead of fully randomizing the bubbles, I adjusted the positioning logic to create a circle formation around the player. This ensured equal spacing between each bubble while maintaining a fixed distance from the player.

Key Code Changes:

Updated AnswerManager.cs:

Before: Bubbles were randomly placed, leading to inconsistent distances and uneven clusters.
Now: The new code evenly spaces bubbles in a circular pattern by:
  • Calculating the angle for each bubble: float angle = (i * (360f / answerOptions.Count)) * Mathf.Deg2Rad;
  • Fixing the distance: float distance = (minDistance + maxDistance) / 2;
  • Setting a constant height: float height = 1.0f;

Problem 2: Bubbles Moving With Players

Issue:

During testing, I noticed the Answer Bubbles shifted when the player moved, making the game feel unstable. Since the bubbles were positioned relative to the camera’s position, they updated whenever the player moved, causing them to "float" unnaturally in the AR environment.

Cause:

The original code positioned the bubbles directly in the camera’s coordinate system, meaning they followed the player’s movement. Additionally, the look-at-camera feature caused the bubbles to constantly rotate towards the player.

Solution:

I introduced a parent GameObject called AnswerBubbles that anchored the bubbles in place relative to the AR camera when generated. All bubbles were instantiated as children of this parent, which remained fixed in the AR space. This ensured they no longer moved with the player.

Key Code Changes:

Updated AnswerManager.cs:
  • Added parent GameObject
GameObject bubblesParent = new GameObject("AnswerBubbles");
bubblesParent.transform.position = arCamera.position;
bubblesParent.transform.rotation = arCamera.rotation;

Updated AnswerBubble.cs:
  • Added SetLookAtCamera() method
private bool lookAtCamera = false;

public void SetLookAtCamera(bool shouldLook)
{
    lookAtCamera = shouldLook;
}

void Update()
{
    if (lookAtCamera && Camera.main != null)
    {
        transform.LookAt(Camera.main.transform);
        transform.Rotate(0, 180, 0);
    }
}

Problem 3: Bubbles Spreadeed 360 Degrees

Issue:

The bubbles spawned 360 degrees around the player, making them hard to find.

Cause: 

The original bubble placement logic positioned the answer bubbles evenly around the player in a full 360-degree circle. As a result, some bubbles appeared behind the player, making them hard to find without physically turning around. 

Solution:

I updated the bubble placement logic to arrange them in a 180-degree arc in front of the player. Each bubble was spaced evenly, ensuring better readability.

Key Code Changes:

Updated AnswerManager.cs:
Before: float angle = Random.Range(0, 360f) * Mathf.Deg2Rad;
After: float angleRange = 180f;

Problem 4: Timer Not Resetting After Correct Answer

Issue:

When the player answered correctly, the game did not reset the timer, meaning players had less time with each new problem.

Cause:

I set the timer only counted down and haven’t been programmed to reset after each correct answer.

Solution:

I updated the ProcessAnswer() method in the GameManager to reset the timer to 30 seconds whenever the player answered correctly.

Key Code Changes:

Updated GameManager.cs:
  • Change the ProcessAnswer()

public void ProcessAnswer(bool isCorrect, GameObject bubbleObject)
{
    if (isCorrect)
    {
        ShowFeedback(true);
        remainingTime = timeLimit;
        Invoke("GenerateNewProblem", 1f);
    }
}

Problem 5: Removing Only the Wrong Answer Bubble

Issue:

The answer bubbles are all cleared if the player chooses the wrong answer. The game felt unfair, as players didn’t get the chance to retry the same equation.

Cause:

The original ClearAnswer() method removed every bubble after each incorrect attempt.

Solution:

I added a new method in the AnswerManager to only remove the wrong bubble the player selected, keeping the other bubbles in place for the same problem.

Key Code Changes:

Updated AnswerManager.cs:
  • Added RemoveBubble() method

public void RemoveBubble(GameObject bubble)
{
    if (bubble != null && answerBubbles.Contains(bubble))
    {
        answerBubbles.Remove(bubble);
        Destroy(bubble);
    }
}

Updated GameManager.cs:
  • Updated ProcessAnswer() to call RemoveBubble()
if (!isCorrect)
{
    answerManager.RemoveBubble(bubbleObject);
}

Insights

Troubleshooting is an essential part of game development. Each test in Pippo Math revealed new opportunities for refinement, from improving visual clarity to enhancing game flow. The iterative improvements not only made the game more polished but also strengthened the overall user experience, turning a simple concept into an engaging and interactive learning journey. With these changes in place, the game now felt smoother, more organized, and visually clearer.

Comments

Popular posts from this blog

Creating UI Elements

The User

Core Mechanics: Building the Math Problem Generator