





video.mp4
A 3D heart puzzle game created using unity and blender to help students figure out the heart parts making it fun and usefull at the same time.
firstly we have to choses the right model to process it on blender using its features. I'm going to put the right steps I took to generate a Mesh-Divided heart model
-
Import the right model
- you can build a heart model in belnder or just select it from any library on google
- open blender and import your model
-
Select the knife
-
Exprot your model
after preparing our model in blender, we will pass it to Unity to build our puzzle game. But before going on the core game, we have just to build a frindly GUI for the user. Here we go:
-
Create a Canvas (Your Screen’s “Drawing Board”)
- In Unity’s Hierarchy window: → Right-click → UI → Canvas. This is where all your buttons/text/images will live.
-
Add UI Elements (Buttons, Text, etc.)
-
For a button: → Right-click on the Canvas → UI → Button. → A Text object will auto-appear inside it. Click the button to rename the text (e.g., “Start Game”).
-
For text: → Right-click on the Canvas → UI → Text. → Type your message in the Text field (e.g., “Score: 0”).
-
-
Adjust Size & Position
-
Select your UI element (button/text) in the Hierarchy.
-
In the Inspector window: → Use the Rect Transform tool (the blue rectangle) to drag and resize it. → Or type exact numbers for Pos X, Pos Y, Width, and Height.
-
-
Make It Look Nice (Optional)
-
Change colors/fonts: → Select the UI element → In the Inspector, tweak:
-
Text Color, Font Style (for text).
-
Source Image (for custom button graphics).
-
-
-
Make Buttons DO Something
-
Create a new C# script (e.g., MenuManager.cs): → In Unity: Assets → Create → C# Script. → Double-click to open it in your code editor.
-
Add this code to the script:
using UnityEngine; using UnityEngine.UI; // Required for UI public class MenuManager : MonoBehaviour { public Button yourButtonName; // Assign in Unity Inspector void Start() { // Make the button call a function when clicked yourButtonName.onClick.AddListener(YourFunction); } void YourFunction() { Debug.Log("Button clicked!"); // Add your action here (e.g., load a scene) } }
-
Link the script to your button: → Drag the script onto the Canvas or any GameObject. → Select the script in the Inspector → Drag your button into the yourButtonName slot.
-
-
Test It!
after creating the GUI let's build the core game. we have to include the modle in unity. Our work is divided into 5 principles including: camera, drag & drop, snap, randomize and Timer. let's talk about each one of them:
The camera is how players view and interact with the heart pieces. Since it’s a 3D puzzle, you’ll want players to see the heart from angles that make solving intuitive.
-
Isometric View: Set the camera at a 45-degree angle to show all heart pieces clearly (like a chessboard view).
-
Zoom & Rotate: Let players rotate the heart or zoom in/out to inspect pieces (e.g., for intricate ventricle or atrium parts).
-
Focus on Selected Piece: When a player clicks a piece, smoothly move the camera closer to it.
Players need to drag heart pieces and place them correctly. This mechanic is the core of your puzzle!
-
3D Dragging: Use OnMouseDrag() or raycasting to let players click and drag pieces.
-
Visual Feedback: Highlight a piece when hovered (e.g., glow) to show it’s interactable.
When players place a heart piece near its correct spot, it should “snap” into place for a satisfying fit.
-
Proximity Check: If a piece is close to its target position, snap it.
-
Rotation Alignment: Ensure the piece’s rotation matches the target (e.g., a ventricle fragment aligns with the heart’s chambers).
Shuffle the heart pieces at the start of each level to create fresh challenges.
- Random Positions: Spawn pieces in random locations around the heart.
- Random Rotations: Rotate pieces randomly to increase difficulty.
Add urgency! Players must solve the puzzle before time runs out (e.g., a "heartbeat" timer).
- Countdown UI: Display a timer bar or numeric counter.
- Penalty/Reward: Lose time for wrong moves, gain time for correct snaps.

- Dr. Tamer Basha All rights reserved © 2024 - Systems & Biomedical Engineering, Cairo University (Class 2028)