---
# System prepended metadata

title: Assignment 2 - AR Foundation basics (ungraded)

---

# Assignment 2 - AR Foundation basics (ungraded)

**Date**: 13/02/2022

**Group members participating**: Jakob Overgaard (201706812), Oilver Rask Schmahl (201805260), Tobias Fabrin Gade (201809466)

**Activity duration**: 4 + 5 + 4

## Goal
Get hands on with AR Foundations in unity and begin thinking about relevant objects with regards to our own concept.

## Plan
Do the exercises.

## Results
**Exercise 1.2**
When running the simple AR application, which can be seen in the image below, it tracks all physical surfaces that it can detect and places planes to mimic them in the virtual space.
<img src="https://i.imgur.com/fEr1o7I.jpg" width="250">


**Exercise 2.1**
To a large extend we have reused the code from the first handin for the ObjectAdder script, with only few changes to how the input works, as we now use the touch input. 

![](https://i.imgur.com/xnum0WR.png)

When cubes are added they are placed neetly in the room and seem to have a size of rougly 20cm by 20cm. Considering the cube's side lengths of 0.2 units, we believe that 1 unit corresponds to 1m in the physical space.

Additionally, when cubes are placed on top of each other they simply stack.


**Exercise 2.2**
When removing the AR Default Plane from our AR Plane Manager we break the Raycast function implemented from our previous assignment. 

To fix this issue we used AR Raycast manager by inserting a serialized field for a Raycast manager, and using the new object to handle and store our hits.

We then added a AR Raycast manager component to our AR Session Origin, and used this as our component variable for the Raycast Manager under our BasicBehavior.

![](https://i.imgur.com/XMYXBHU.png)


When running the code we are now able to add multiple cube objects, however the cubes fall through the ground. This is because there is no plane with a collider, which the objects can collide with and therefore when rigid body is enabled they fall.

<iframe width="250" height="562" frameBorder="0" src="https://imgflip.com/embed/651oxa"></iframe>

By disabling the physics on our cube prefab (rigid body) we are able to make sure that the object stays in the location that it is instantiated in.

<iframe width="260" height="574" frameBorder="0" src="https://imgflip.com/embed/651pjf"></iframe>

Because we removed the physics from the object, it does not collide with other spawned objects. This means that the objects spawn in each other, instead of spawning on top of the existing objects.

<img src="https://i.imgur.com/stTHTJD.jpg" width="250">

AR Raycast only hits objects that are of the type ARTrackableObject, thus this raycast function will not be able to interact with normal objects in a scene. In contrast the normal Raycast function interacts with normal game objects, but dose not care about ARTracableObjects.

We can combine these two to have e.g. a placement marker that gets positioned on the AR planes using the AR raycast, while when we place an object, we want to use a normal raycast to see if the new objects should be placed on top of other objects already spawned in the scene. 

Additionally we simply chose to disable the rendering of the AR default planes, such that they could not be seen by a user.

**Exercise 2.3**
The code for our indication marker can be seen here.
![](https://i.imgur.com/ohj7TtS.png)


**Exercise 2.4**
Our UI button is simple made from the UI button component, where a function is then called inside RealObjectAdderScript to add an object at the markers location.
![](https://i.imgur.com/oBZeEP2.png)
![](https://i.imgur.com/sDcvNHR.png)

It was unclear from the assignment how this button was intended to work, we chose to have it spawn the object as soon as you hit the button rather than having to press the button and then the screen. 

**Exercise 2.5**
Since we want to create a app to show prestine museum objects besides broken or faded ones we found a sculpture for our object.
The sculpture placed with AR can be seen in the image below. 

<iframe width="260" height="562" frameBorder="0" src="https://imgflip.com/embed/651q0m"></iframe>

**Exercise 3.1**
When tracking an image and moving it the object we place on top of the tracked image followes the movement in the physical space.

![](mona)
**Exercise 3.2**

When tracking two images with the same physical size and adding the same MO to them, while one of them is set to the right real world scale and the other is 2 times as big the MO spawned from the twice as "big" images becomes half the size - because this influences how big unity thinks the model should be.
