Studio: The Cost is Correct
Overview
The Cost is Correct is an engaging app where users take photos of objects, and the app generates a multiple-choice quiz about the object's price. Users must guess the correct price from four options. Points are awarded for correct answers, and progress is tracked on a leaderboard. A single incorrect answer resets the user's score to zero, encouraging precision and accuracy.
Controls
- Take Photo Button:
Captures an image of an object and generates a price-related quiz question. - Answer Options (A, B, C, D):
Select from four possible price options for the object. - Leaderboard:
Tracks and displays the user's highest score (Best) and current score.
Components
Random Quote API
Description:
Handles the quiz generation and scoring mechanism based on the Gemini API and user interactions.
Schema:
- Question: Entity ID for displaying the generated quiz question.
- Ans1, Ans2, Ans3, Ans4: Entity IDs for the four multiple-choice answer options.
- Score: Entity ID for displaying the current score.
- Best: Entity ID for displaying the user's highest score.
Data:
- content: Stores the quiz content received from the Gemini API.
Functionality:
- Image Capture: Takes a screenshot of the AR scene and uses it to generate a quiz question.
- API Request: Sends the image and a prompt to the Gemini API to create a multiple-choice quiz.
- Answer Validation: Compares the user's choice with the correct answer, updating the score or resetting it on incorrect answers.
- Leaderboard Update: Tracks and updates the user's highest score.
Project Setup
Main Entities:
- Take Photo Button: Initiates the quiz generation process.
- Answer Buttons: Allows users to select one of the four price options.
- Score and Best: Displays the user's current and highest scores.
Organization:
- The component is registered using the ECS framework and manages quiz generation and user interactions.
Customization
API Key Configuration:
Replace in the Gemini API request with your valid API key.Quiz Prompt Customization:
Modify the string in the function to change the style or type of quiz questions.UI Adjustments:
Customize the text size, button colors, and layout for the question and answer options.
Technical Details
Gemini API Integration:
The app uses the Gemini API to generate quiz questions based on captured images.Score Logic:
Points increase with each correct answer, but a single incorrect answer resets the score.Error Handling:
Includes robust error handling for API failures or invalid inputs.UI Updates:
Dynamically updates the question, answers, and score using ECS UI mutation functions.
Input Manager
Mapped Actions:
- Click:
- Binds the function to the photo button.
- Handles answer selection and validation.
Asset Attribution
- Gemini API:
Provides generative quiz content. - Niantic Studio:
Used for AR functionalities and ECS framework. Also used XR8 for screenshots
Other Work by GTXR Club