This tutorial is designed to guide you in integrating Augmented Reality (AR) into the classroom. AR provides an interactive experience of a real-world environment, enhanced by computer-generated information. You will learn how to create an AR app using Unity3D and Vuforia SDK.
What you will learn:
Prerequisites:
AR overlays digital content on the real world. It allows students to interact with virtual content in a real-world context, enhancing learning experiences.
We will use Unity3D, a game development platform, and Vuforia SDK, which allows AR functionality.
Installation:
// This is a C# script in Unity3D
// Import the Vuforia Engine package
using Vuforia;
public class ARScript : MonoBehaviour
{
// This method will start tracking
public void Start()
{
VuforiaBehaviour.Instance.enabled = true;
}
}
This script enables the Vuforia engine when your app starts.
// This is a C# script in Unity3D
// Import the Vuforia Engine package
using Vuforia;
public class ARScript : MonoBehaviour, ITrackableEventHandler
{
private TrackableBehaviour mTrackableBehaviour;
// Initialization
void Start()
{
mTrackableBehaviour = GetComponent<TrackableBehaviour>();
if (mTrackableBehaviour)
{
mTrackableBehaviour.RegisterTrackableEventHandler(this);
}
}
// This method will be triggered when the target is found
public void OnTrackableStateChanged(
TrackableBehaviour.Status previousStatus,
TrackableBehaviour.Status newStatus)
{
if (newStatus == TrackableBehaviour.Status.DETECTED ||
newStatus == TrackableBehaviour.Status.TRACKED ||
newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED)
{
// Target found
OnTrackingFound();
}
}
private void OnTrackingFound()
{
// React to the target being found, like displaying a message
}
}
This script detects an image target and triggers an event when the target is found.
You have now learned the basics of AR and how to create an AR app using Unity3D and Vuforia SDK. You can explore creating more interactive and educational AR apps.
Next steps for learning:
Additional resources:
Exercise 1: Create an AR app that displays a 3D model of a planet when a specific image target is detected.
Exercise 2: Create an AR app that displays a historical fact when a corresponding image target (like a photo of a historical event) is detected.
Solutions:
For displaying a 3D model of a planet, you would need to import a 3D model of a planet into your Unity project. You can then set this model to appear when the image target is detected.
For displaying a historical fact, you can use Unity's UI Text to display text when the image target is detected.
Tips for further practice: