Plant AR experiment for iOS

Patrick (my boyfriend who does 3D modeling) and I recently decided to do a weekend “hackathon” AKA a hackathon where you don’t meet anybody new and everything is inside your own house.  I would argue that such a hackathon is THE BEST type of hackathon since the end goal is only learning 🙂

We wanted to make something simple since it was the first time we ever collaborated on a AR/VR project, we didn’t want it to be longer than a day’s worth of work, and we wanted to be able to create and deploy it on our own devices.

I used Vuforia for the image recognition (anytime it sees that particular image printed on the paper, our script and scene will execute), Unity, the iOS SDK for Unity, and XCode to compile the code. Patrick used Cinema 4D to create the plant and animation and imported his assets into Unity.

Here’s the “final” product on our iPad –

It was my first time to develop something that would be deployed to an Apple Device, so I had to go through signing up for a developer account, getting verified, and using XCode to actually deploy my code (rather than only using it for its iPhone emulator feature like I usually do at work).  Attempting to troubleshoot all the “Code Signing” errors in XCode was probably the hardest part of this process.

If you’re curious, here is the tiny piece of code I used for the touch event –

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlantGrow : MonoBehaviour {
  Animation anim;

  // Use this for initialization
  void Start () {
    anim = GetComponent<Animation>();
    Debug.Log("Start");
  }

 // Update is called once per frame
  void Update () {
   if(Input.GetMouseButtonDown(0)){
     anim.Play("grow");
     Debug.Log("Your plant is growing!");
   }

  }
}

You might notice that Input.GetMouseButtonDown(0) is referring to a PC rather than a touch device,  but it still works!  I’m assuming it is similar to making a website mobile friendly, all the click events still typically work on touch devices.

I am curious how Unity deals with touch events (like swipes / drags / etc.), however, and that is something I am going to look up ….now 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s