Lovelock XR: Position Virtual Lock in Realworld Space

“As a player I want to position my lovelock in the realworld so that it stays in the same place. “

Week Ten User Story Sprint


Originally, I had aimed to allow players to place a virtual lovelock in a realworld physical location. For example, a player would be able to attach their virtual lovelock in any position where a physical one could be attached, such as a horizontal bar forming part of a larger structure like a bridge. However, I had to cede that this would not be possible with my current skillset and maybe not even within the scope of currently available technology.

Technical Research

During the early stages of preparation for my app I researched a number of software development kits, including Vuforia, Wikitude, ARCore and ARKit. However, I was unable to confirm that any of these SDK’s would allow me to identify physical structures through a device’s camera, to which a physical padlock could be attached; letalone simulate associated physical behaviour such as positioning the virtual lock ‘hanging’ from it’s anchorpoint or sliding down a sloped horizontal bar, etc.

One potential solution I considered was developing 3D models of selected bridges in major cities and training my app, using Vuforia’s Object Recognition to track and recognise rigid objects. However, this would prove to be a huge undertaking in terms of time and technology for scanning and creating 3D representations of selected bridges. I therefore concluded that I would aim to work with the technological solutions which are readily available within Vuforia to allow a player to place a virtual lovelock in the air or on any flat plane using Vuforia’s Ground Plane functionality and extended tracking. This decision opened up greater potential for playability of the app as it would no longer restrict the app to being used on specific bridges or even limited to permanent structures at all.

Ground Plane Positioning

According to the documention on the official Vuforia developer library, “Vuforia Ground Plane enables digital content to be placed on horizontal surfaces in your environment, such as floors and tabletops“. This would work great for my app, if my players can position ground based lovelock objects on steps, park benches, car parks, pavements and so on.

Having installed the Vuforia Unity SDK within my project’s assets, I began by configuration. This mainly entails adding an app license key from Vuforia and setting up a webcam to test with. I also needed to print out an emulator ground plane for testing purposes.

To enable Vuforia Ground Plane within my scene, I first replaced the default Unity Camera game object with an ARCamera from the Vuforia Engine selection in the main GameObject menu. Next I placed a Ground Plane Stage, also from the Vuforia Engine sub-menu, within my scene and added a 3D LoveLock object inside of it. Finally, I added a Plane Finder. This type of GameObject is responsible for the scripts that control the interactivity between the user and the Plane detection/positioning. The only mandatory change to this object is to set the previously added Ground Plane Stage as the Anchor Stage for this object’s Content Positioning Behaviour script.

Setting Anchor Stage

Next, using my portable webcam (Microsoft LifeCam HD-3000) to simulate a mobile device camera along with the Ground Plane Emulation print-out, I am able to test my scene by placing my 3D test LoveLock in-situ, on my desk. The LoveLock remains firmly at it’s anchor point, even when I point the webcam elsewhere and return to the original point.

Vuforia Ground Plane Demo

Mid Air Positioning

Mid air positioning is a similar setup to ground plane. The game objects are called mid air stage and mid air positioner and are located inside the Vuforia Engine submenu of the main GameObject menu. The mid air stage is set as the anchor stage within the mid air positioner game object’s “Content Positioning Behaviour” component.

Setting Air Stage

There is an option to Duplicate Stage which I have left unchecked as I only want my player to be able to place one virtual object per view. Selecting this option would allow a user to add many instances of the virtual object to the scene.

The emulation works similarly to ground plane detection. The same emulation print out is used to set and reset the position selection. Instead of a perspective grid, which is used to ackknowlede plane detection, air positioning simply provides a 3D object, a green sphere by default, in the central view of the camera to indicate where the virtual object will be positioned. I found air positioning to be a little less reliable than ground plane positioning in terms of persistance. For example, when placing at a point in the air and then directing my camera away and then back again, the lovelock will sometimes have moved. However, this is only in emulation mode. The accuracy of tracking when the target is no longer in the field of view depends on the hardware/software of the device. For example, when available, Vuforia will automatically default to ARKit or ARCore which provide more accurate levels tracking than Vuforia’s default tracking. Extended tracking performance also varies depending on the environment. I am currently testing in a fairly somber office with little natural light. I look forward to having a working demo of my app on my mobile device (Google Pixel 3 with ARCore) to go outdoors and test tracking and positioning.

Leave a Reply