Sitemap

Making AR Mysterious game in Unity3d.

4 min readApr 26, 2025

Objective: Making AR Mysterious game in Unity3d.

In the first step I will follow all the step to place object in the AR environment once, to do this I will follow every step then disable AR Placement Interactable when we place the magic box.

Note: I have cover this step in previous article here the link https://medium.com/@suleimanabdullah/working-with-ar-interactable-5fb1ad03766e

Press enter or click to view image in full size

In this step we need to set our skull to have all examinable features we created in the previous article.

Here is the link to follow step by step how I created Examinable object https://suleimanabdullah.medium.com/how-to-make-examinable-object-in-ar-with-unity3d-fb4b0d8e8dbc

Press enter or click to view image in full size

Create two script Box Manager and Germ ,attach Box Manager to a box with three diamond on top of it and and attach Germ script to each germ object.

Open Box Manager script and create the following variable and these two method.

Press enter or click to view image in full size

Go to Germ script and create this variable type .

Press enter or click to view image in full size

Go to GermSelect method ,add the name of Germ to the string called EnterGermOrder ,we do this by use Germ parameter and increment the string we create from the Germ script.

Then each time we click the germ we need to count how many germ we click we do this by increment currentAmountOfGerm.

Note: By now am thinking what happened if user click same germ twice, but hey lets implement this simple solution and try not to confuse some one who is only start to code recently.

If the currentAmount of Germ is equal to amountOfGerms we called CompareGermOrder.

Press enter or click to view image in full size

Create another two method called ResteGame and OpenBox in the BoxManager.

Go to CompareGermOrder, check enteredGermOrder is equal to correctGermOrder ,it condition is true we call OpenBox or we call ResetGame.

Press enter or click to view image in full size

When we call OpenBox we trigger animation and ResetGame we reset this two variable.

Note: Our box has animator and Open is set as parameter to trigger in the animator for playing animation.

Press enter or click to view image in full size

Go to the Germ each game object<Inspector<Germ, type a name of the color for variable we created early. Last add AR Selection Interactable to all of the Germ object

Press enter or click to view image in full size

Select each germ <Inspector <AR Selection Interactable ,add event to each of them select box to game Object then set GermSelect as function in the event, lastly drag and drop the germ in the field of the method.

Press enter or click to view image in full size

Bonus here is the code to add emission to a germ when we select it.

Press enter or click to view image in full size

Go to Box Manager

add each game to the number of array in the inspector
Press enter or click to view image in full size
call Change Emission and set the its parameter to true
Press enter or click to view image in full size
loop through array and set the function parameter to false to remove emission to the germs

Select the Germ and drag and drop the material to the inspector

Press enter or click to view image in full size

Note: the clue for correct order you will get when you rotate the skull, this according to me you can do whatever order you wish.

See you into the next one.

--

--

Suleiman Abdullah
Suleiman Abdullah

Written by Suleiman Abdullah

My name is Suleiman Abdullah. I learn game development and share what I learn by writing articles. :https://ko-fi.com/suleimanabdullah

No responses yet