Hello everyone,
This is going to be our last post, we enjoyed a lot working on mixed realities in Unity and we are sure we will use the knoledge we have acquired in the future.
On this one we will comment and explain some code snippets:
MatChanger.cs: Game Menu Controls
To control the game menu / instructions panel we wanted to put some buttons on the bar counter but we had some issues with that and we weree running out of time so we finally put the buttons under the screen where it is all showed.
This is the code we use to controll the 2 buttons we have, one of them to navigate through the cocktail menu, and the second one is to get started and go to the next slide:
Here, a 2 dimensional array with the name of every material for the screen is created. We use CocktailNr to save the first index if the array and SlideNr to save the second index. On Start, we assign the Slidescreen.
This functions are called after we press the UI buttons below the screen. They increase SlideNr or CocktailNr and call the UpdateScreenMat function with the updated indexes. The UpdateScreenMat is explained in the following.
It loads the correct material based on the Name. Afterwards it changes the material of the previously assigned Screen.
Streams.cs: "liquid" stream
splashParticle: Creates the particle "splash" effect on the end of the stream.
pourRoutine: Responsible for the updating pouring based on degrees of the bottle.
targetPosition: Detects the bottles' degrees.
FindEndPoint() creates a raycast from the top of the bottle straight down until it detects collision, and pours to the detected spot.
AnimateToPosition() creates the animation for the pouring of the stream with the a given speed Time.deltaTime * 1.75f.
PourDetector.cs: Detects the pouring
origin: starting coordinates where the pouring is coming from.
currentStream: will create the pouring streams based on the if stament below.
Update(): Checks if the pouring is happening and will StartPour() or EndPour() based on the treshold.
If you want to try it by yourself, the project is already completed and uploaded on our github repo: https://github.com/Yasin-0109/Bartender-Tranning
Sadly, this is all for this course! We had great fun developing the applications for AR and VR, and we hope you enjoyed checking our progress updates on the blog.
I recomend everyone interested in coding to check out this technologies and see its possibilities, for sure we will keep doing it so stay alert just in case we decided to start another blog about other work we do!!

Comments
Post a Comment