Star Wars Augmented Reality Tutorial: User Defined Targets with Vuforia and Unity 3D

This tutorial is designed for anyone beginning with mobile development and augmented reality. We will go through how to modify the sample scene for user defined targets in Unity 3D with the Vuforia SDK. Vuforia requires the use of a fiducial marker or image target in order to augment a 3D object. The image it requires lets your mobile device know where the augmentation is to occur, and is often used to create a ground plane so you can place objects on top of it. The app we are going to make with this tutorial will allow the user to a picture of any image they want, and the augmentation will occur immediatly on top of that image. This is much less cumbersome than creating a predefined image that the user must print out in order to use the app. This tutorial does not require any previous experience with Unity or Vuforia so it should be very quick and easy to implement.

Full Text Instructions can be found here: Star Wars AR



atScript.cs


using UnityEngine;
using System.Collections;

public class atScript : MonoBehaviour {

  // Use this for initialization
  void Start () {
  
  }
  
  // Update is called once per frame
  void Update () {

    transform.Translate (Vector3.forward * .01f * Time.deltaTime); 
    transform.Rotate(Vector3.up * 3f * Time.deltaTime);

  
  }
}



controllerScript.cs


using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class controllerScript : MonoBehaviour {

  public Button fireButton;

  // Use this for initialization
  void Start () {

    fireButton.onClick.AddListener (OnButtonDown);


  }
  // Update is called once per frame
  void Update () {



  }


  void OnButtonDown(){

    GameObject bullet = Instantiate(Resources.Load("bullet", typeof(GameObject))) as GameObject;
    Rigidbody rb = bullet.GetComponent<Rigidbody>();
    bullet.transform.rotation = Camera.main.transform.rotation;
    bullet.transform.position = Camera.main.transform.position;
    rb.AddForce(Camera.main.transform.forward * 500f);
    bullet.GetComponent<AudioSource>().Play ();
    Destroy (bullet, 3);




  }

}//end of file



Hey !!!

about me.

My name is Matthew and I attend the University of Pittsburgh. Currently I am a Senior, going for a bachelors in Information Science with a minor in computer science. I work as a food server when I am not at school, but would love something a little more technical, if anyone is hiring.

  • Pittsburgh, PA
  • MatthewHallberg@gmail.com

Drop me a line

For free lance work
or consulting.
Send inquiries to:
MatthewHallberg@gmail.com