Making AR Mysterious game in Unity3d.
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
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
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.
Go to Germ script and create this variable type .
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.
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.
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.
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
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.
Bonus here is the code to add emission to a germ when we select it.
Go to Box Manager
Select the Germ and drag and drop the material to the inspector
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.