Troll and Dragon project

Spark Emerging Technogies

For my first semester I decided I wanted to gain first hand expereicne in the augmented reality industry. As a result I approched SPARK EMERGING TECHNOLOGY LAB who are the UK's leading augmented reailty agency, and I have been a huge admirer of theirs over the last couple of years within the AR agency.

Role in the company

Being an intern in SPARK, my role was to undertake AR projects that the developers did not have time to build/ update. In this case the project I undertook first was the Troll and Dragon AR client demonstration. I had a limted time frame to work on a project, which meant I didnt have time to plan out the project's trajectory.

Documents

  1. NLT 1 Document

The Problem

The project was built using unity 5.6 2017 version where it used Vuforia to augment the Troll and Dragon, which was outdated in the current augmented reality industry due to the majority of AR single user mobile apps being built using AR foundation. The AR features, UI were all outdated, including the textures of the models.

I began to test out the previous placepoint scripting within the application. The surface detection on the old AR placepoint mapping with Vuforia, detects any flat planes. In this case it is the floor and table to allow the model to be augmented. This version was not suitable at all, as it physically outlines the flat planes in a yellow marker disrupting the overall look of the application.
Both models have animations, with the Troll walking forward and backwards and the Dragon flapping its wings.

On the left the troll appers upon pressing the troll button below, however the scanner hasn't properly tracked the floor which leads to the troll walking into the wall beyond the scanned area. Another problem that arose, was that that plane manager kept on identifying multiple planes without removing them.
The troll also had no ability to modify the state of the model such as it's size or positioning of the troll.

The Solution ✅
Development- WEEK ONE 🗓️

To begin with, I started by impelmenting AR foundation into the project with the AR 'placetopoint' script. This script will enable the AR to identify a flat plane for the Augmentation to occur. In this case the Raycast manager manages the raycasting of the postitoning indicator of the troll, as seen under the public void placetroll. From here the code transforms the positioning of the troll when the 'place troll' button is pressed.

In order for the script to find a flat surface, I used the prexisitng vector two script that divided the screen into 2/2 on the X axis and Y axis to allow for a 3D Cube/ sphere to be placed in the center of the screen.

Next I implemented a scaling script which I located online called Pinch to Zoom. It allows for the model to be scaled to any size depending on the user's preference.
As you can see the public class is 'Pinch ToZoomScript' with 'vector 3' targeted for scale of the model. 'SmoothTime = '0.3f' is the speed to which the model will reach the desired size of the target as a float (real number).

Lower down the script is the input touch, which takes the input of the two fimger for the scaling of the model.

As you can see the troll is able to scale up and down sucessfully depending on the user's choice. However the animation of the troll scaling up and down is very shaky and not to a professional standard. Therefore I implemented an additional part of the script.

By adding 'SmoothDamp' and the end of the Vector3, the model scales smoothly. This was found on a unity forum Smooth Damp.

As the troll shows, the model increases and decreases in size in a smoother fashion. In turn the model appears in a much more professional look.

One bug I encountered when developing the application, was the dragon constantly bouncing above the troll when scaling downwards. This was partly due to the animation of the troll walking forward, colliding with the dragon's animation of flying up.

Testing outside

In order to gauge how the model would function, I took the application outside and practised scaling it up and down. This gave me a good indication on what the model would look like at full size.

I then deployed the dragon element of the project which gave me a good indication that the scaling of the 3-D objects were scaling effectively.

Despite this, I identified key areas that needed to be improved during the testing to improve the professionalism of the application:

- Enable the application to reset the dragon and troll's position

- Implement Rotation

- Change icons and 3D raycast shape

- Upgrade URP shaders from SRP

- Adding shadows

- Fixing Dragon bouncing problem

Adding Rotation

I found an online script from stack overflow that would enable me to implement the rotation script into to application.
StackOverflow rotation script
In this case the 'input.touchcount == 1' signifies the amount of fingers on the screen to rotate the object, with the boolean expression &&. && is a logical operator where it determines logic between varlibles or values.

For example, it will return true if BOTH statments are true. In this case the touch input would have to be equal to (==) 1 AND holding. ! will reverse the outcome if that is not the case.

0.5f is the speed to which the troll can be rotated. 'f' is a float varible which in this case treats 0.5 as a number.

After implementing the script, I was able to rotate the troll around the area as well as scaling it at the same time.

Week 2- Dragon Bouncing

To work out why the dragon was bouncing up and down above the troll, I inspected the pre-existing dragon fly up script that was pre-existing with the project. However upon looking into it there was no indication that the script was faulty.

I also thought it was down to the distance of the colliders clashing with each other, however after setting a main height for the dragon and troll, it still did not fix the problem. I then tested out to see if the two models would stop colliding if they were in the same 'parent' (empty game object).

As a result, scaling was consistent together, rather than separate. This therefore stopped them from interfering with each other, causing the bouncing effect.

As you can see on the left, the dragon no longer bounces up and down when above the troll. Since the two models are a child of the same parent, their colliders no longer constantly collide with each other, which casused the dragon to go up and down.

Upgrading to URP (Universal Render Pipeline)

Next, in order to get the very lastest textures and shadows, I decided to upgrade the render pipeline from SRP (Standard Render Pipeline) to URP. This was done by going into Edit> Render Pipeline> Upgrade Project to Universal URP Materials. Afterwards this led to the 3D model going pink due to the shaders changing.

After the URP installed, I went into the project window and dragged the URP into the Scriptable Render Pipeline asset. As a result, the model's textures were then updated to the 2021 version compared to the previous 2017 textures.

Once the URP was installed, the AR monsters now cast shadows in accordance to the model's position. Both the troll and dragon's shadows are cast onto the ground with perfect realism and intensity, such as the holes being raycasted on the ground through the dragon's wings.

In terms of the quality of the texture upgrade, both models showcase the new upgraded textures.

During the development of the application there was a strange bug. The cube would not disappear upon turning on the troll and dragon.

Week 3- Debugging, Sound effects and UI

In order to fix the bug, I intergrated a 'reset animation' script which resets the current scene to the the original scene.

Next I changed the 3-D object into a sphere and added in the companies logo as the main material. This allowed for a more professional look rather than a blank cube as the plane indicator.

In order to make the application seem more realistic, I added in mob sound effects to the dragon and the troll once spawned. As shown on the video, the sounds are immediately deployed upon spawning.

Final Outcome 🏆

The final outcome for the project, was a fully functional and animated trolled and dragon AR application. Upon placement, both the Troll and Dragon showcase moving and animated sound effects to increase the realism the user will experience.

 

Reflection and Analysis

To reflect on this project, I have learned a great deal about the basics of AR foundation within unity. Before this project, I was only experienced with Vuforia Engine when building AR applications, but was extremly intrigued to learn about the latest and industry standard methods of building augmented reality applications in unity. As a result of learning AR foundation and building out the Troll and Dragon project, my C sharp knowledge has greatly improved as I have been working alongside industry specialists furthering my understanding of how these applications are built in 2021. This has therefore enhanced my coding skills and interpretation of the way AR Foundation, C sharp and Unity game engine can integrate together to create an AR application for iOS and Android. The challenges I faced were primarily due to C sharp coding errors or down to the colliders within the project not cooperating with each other, which I overcame by debugging. Overall I'm very happy with the integration to AR foundation that this project has showcased and I have learnt a lot from the development of it.

Time management

I structured my time management on a week by week basis, where I made sure that I took each stage into account.The Troll and Dragon project only consisted of three weeks, with a Lamborghini project consisting of four. This was down to the amount of development work required to build out the application. The Funko pops however stretched between week seven and week twelve, as they were far more in-depth and required many more C sharp scripts and development work to occur to them. Overall I was happy in the way I managed my workload and found it to be a success.

Handover information

Upon handing in the augmented reality application, the relevant files were all stored on Spark labs computers. As Spark own the projects and the files are on their computers/ databases, they do not need handover documentation.

Work place reference

Here is my workplace reference from Spark:

Reference

References

  1. Spark Lab- https://www.spark-lab.co.uk/

  2. Vuforia- https://www.ptc.com/en/products/vuforia

  3. Smooth damp- https://docs.unity3d.com/ScriptReference/Vector3.SmoothDamp.html

  4. Pinch to Zoom- https://www.youtube.com/watch?v=ISBIu6Jzfk8

  5. Rotation- https://stackoverflow.com/questions/57790059/rotating-an-object-at-which-i-am-looking-arfoundation