Let’s Make an AR App in 15 MINUTES!! (Beginner Friendly)

immersive insiders
16 Nov 202217:31

Summary

TLDRThis tutorial offers a step-by-step guide to creating an AR application in Unity, where users can scan an image to spawn a dragon and control its movement using a joystick. The video promises to teach the entire process within 15 minutes, covering software setup, Unity Hub installation, necessary modules, and package downloads. It guides viewers through project setup, scene creation, and scripting for image tracking and dragon control, concluding with a live demonstration of the AR application on an Android device.

Takeaways

  • 😀 The video provides a step-by-step guide to creating an AR application where a dragon can be spawned by scanning an image and controlled using a joystick.
  • 🛠️ Unity software is required for the development of this AR application, and the video instructs viewers to download and install Unity Hub and the specific version 2021.3.6.
  • 📱 The tutorial emphasizes the need for specific modules like Android support, Android SDK, NDK tools, and Open JDK for successful Android application development.
  • 🔍 The AR Foundation and AR Core XR Plugin are essential packages that need to be installed from the Unity Package Manager for AR functionality.
  • 🐉 The dragon model and joystick pack are assets that are used in the application, and the video provides guidance on how to download and import them into the Unity project.
  • 📸 An image is required for the AR image tracking feature, and the video explains how to set up the image tracking within the Unity project.
  • 💻 The video demonstrates how to write scripts in Visual Studio to handle the spawning of the dragon prefab and the joystick control for moving the dragon within the AR environment.
  • 🎮 The joystick control is implemented through a script called 'DragonController' that uses the Rigidbody component to move the dragon based on joystick input.
  • 📱 The video concludes with instructions on how to build and run the AR application on an Android device, including enabling USB debugging and building the project.
  • 🔧 Detailed settings adjustments in Unity, such as graphics API, multi-thread rendering, and scripting backend, are covered to ensure the application runs smoothly on Android devices.

Q & A

  • What is the main goal of the video?

    -The main goal of the video is to guide viewers through the process of creating an AR application where they can scan an image to spawn a dragon and control its movement using a joystick, all within about 15 minutes.

  • What software is required to start the project?

    -To begin the project, viewers need to have Unity software downloaded and installed, specifically the Unity Hub, which manages projects and different versions of the editor.

  • Why is Unity Hub used in this project?

    -Unity Hub is used to manage all Unity projects and to handle different versions of the editor, as well as to add various modules required for specific project needs.

  • What is the significance of downloading the LTS release of Unity?

    -The LTS (Long Term Support) release of Unity is significant because it is more stable, having fewer bugs, and any that exist are typically rectified by updates.

  • Which Unity version is recommended for this project?

    -The recommended Unity version for this project is 2021.3.6, as it is the version the tutorial is based on, making it easier for the creator to assist with any issues.

  • What are the necessary modules for the project in Unity?

    -The necessary modules for the project include Android build support, Android SDK and NDK tools, and Open JDK.

  • Why is the AR Foundation package important for this project?

    -The AR Foundation package is crucial as it provides the necessary tools and components for building augmented reality applications in Unity.

  • What is the purpose of the AR Core XR Plugin in the project?

    -The AR Core XR Plugin is used to enable augmented reality features specifically for Android devices, allowing the application to interact with the user's environment.

  • How does the image tracking work in the AR application?

    -The image tracking in the AR application works by using the AR Tracked Image Manager component, which tracks a specific image and instantiates a prefab when the image is detected.

  • What is the role of the joystick pack asset in the project?

    -The joystick pack asset is used to create a user interface element that allows the user to control the movement of the dragon within the AR environment.

  • How is the dragon prefab instantiated in the AR scene?

    -The dragon prefab is instantiated when a tracked image is detected by the AR system. A script named 'Prefab Creator' is used to spawn the dragon prefab at the location of the detected image.

  • What settings are necessary for the Unity project to run on an Android device?

    -For the Unity project to run on an Android device, settings such as graphics API, multi-thread rendering, scripting backend, and ARM 64 support need to be adjusted according to the script's instructions.

  • Why is it important to set the scripting backend to IL2CPP?

    -Setting the scripting backend to IL2CPP is important for performance optimization and compatibility with certain Android devices.

  • How does the 'Dragon Controller' script enable movement in the AR application?

    -The 'Dragon Controller' script enables movement by accessing the joystick's X and Y values to calculate a movement vector, which is then applied to the dragon's Rigidbody component to move it within the AR environment.

  • What is the final step to test the AR application on an Android device?

    -The final step to test the AR application on an Android device is to connect the device to the computer, enable USB debugging, and build and run the project in Unity.

Outlines

00:00

🛠️ Setting Up Unity for AR Development

This paragraph outlines the initial steps for setting up Unity for AR application development. It emphasizes the need for downloading and installing Unity Hub, selecting the appropriate LTS release (2021.3.6), and installing necessary modules like Android support, Android SDK NDK tools, and Open JDK. The user is guided to create a new Unity project using the 3D core render pipeline and to name it 'AR Image Tracking.' The paragraph also instructs on downloading and importing necessary packages and assets such as AR Foundation, AR Core XR Plugin, a detectable image, a dragon model, and a joystick pack, all of which are crucial for the AR application being developed.

05:02

📱 Configuring Unity Project for Android

The second paragraph focuses on configuring the Unity project for Android development. It details the process of switching to the Android platform in the build settings, adjusting player settings to include the ARCore XR plugin, and ensuring the correct graphics API and scripting backend are selected. The paragraph also covers the creation of an image library for AR image tracking and the setup of an AR session origin with an AR tracked image manager component, which is essential for detecting and tracking the image used to spawn the dragon model in the AR environment.

10:03

🐉 Creating and Preparing the Dragon Prefab

This paragraph describes the process of creating and preparing the dragon prefab that will be spawned in the AR application. It involves resizing and positioning the dragon model, adjusting its animations to ensure it takes off and flies forward, and setting up the dragon prefab in Unity with the appropriate offset to account for its base and center. The paragraph also covers the creation of a new script called 'Prefab Creator' in Visual Studio, which is responsible for instantiating the dragon prefab when the image is detected by the AR system.

15:05

🕹️ Implementing Joystick Control for the Dragon

The fourth paragraph explains how to implement joystick control for the dragon in the AR application. It involves adding a joystick to the Unity scene, creating a 'Dragon Controller' script to manage the dragon's movement based on the joystick's input, and setting up the dragon prefab with a Rigidbody component for physics-based movement. The script calculates the movement direction based on the joystick's X and Y values, updates the dragon's velocity accordingly, and rotates the dragon to face the direction of movement. The paragraph concludes with instructions on adding the joystick to the scene, configuring it, and testing the application on an Android device.

Mindmap

Keywords

💡Unity

Unity is a powerful game development engine used to create 2D, 3D, virtual reality, and augmented reality games. In the video, Unity is the platform where the AR application is developed. The script mentions downloading and installing Unity Hub, which is used to manage projects and different versions of the Unity editor.

💡AR Foundation

AR Foundation is a set of software components provided by Unity that simplifies the process of building augmented reality applications. The script refers to installing the AR Foundation package, which is essential for creating the AR application that can detect images and spawn a dragon model.

💡AR Core

AR Core is a platform by Google that enables building augmented reality experiences. In the context of the video, the script instructs to install the AR Core XR Plugin, which is used to support AR functionality in the application being developed.

💡Joystick

A joystick is a user interface device that allows users to control the position or orientation of an object in a video game. The script describes adding a joystick pack asset to the project, which is used to move the dragon model around after it has been spawned in the AR environment.

💡Image Tracking

Image tracking is a technology used in augmented reality that allows the device to recognize and track the position of a specific image in the real world. The video's theme revolves around creating an AR application where image tracking is used to spawn a dragon when a specific image is detected.

💡Prefab

A prefab in Unity is a reusable object or component that can be instantiated multiple times in a scene. In the script, the dragon model is referred to as a prefab, which is instantiated when the image is detected, allowing users to interact with it in the AR environment.

💡Android SDK and NDK

The Android SDK (Software Development Kit) and NDK (Native Development Kit) are tools used for developing Android applications. The script mentions installing these tools as part of the setup process for developing the AR application for Android devices.

💡Rigidbody

A Rigidbody is a component in Unity that adds physics to an object, allowing it to move and interact with other objects in the scene. In the video, a Rigidbody component is added to the dragon prefab to enable movement controlled by the joystick.

💡Scripting

Scripting in Unity involves writing code to define the behavior of objects in the game or application. The script describes creating and editing scripts such as 'PrefabCreator' and 'DragonController' to handle the spawning of the dragon and its movement within the AR environment.

💡Canvas

In Unity, a Canvas is a UI component that allows for the creation of user interfaces. The script mentions adding a Canvas to the scene to house the joystick UI, which is crucial for the user's interaction with the AR application.

💡Build Settings

Build settings in Unity refer to the configuration options for compiling the project into a final executable for a specific platform. The video script includes instructions on setting up build settings for Android, which is necessary to deploy the AR application onto an Android device.

Highlights

Create an AR application to scan an image and spawn a dragon in about 15 minutes.

Download and install Unity software from unity.com/downloads.

Use Unity Hub to manage projects and editor versions.

Download LTS releases for stability in Unity editor versions.

Select Unity version 2021.3.6 for compatibility with the tutorial.

Install necessary modules: Android build support, Android SDK, NDK, and Open JDK.

Create a new Unity project with the 3D core render pipeline.

Download and import AR Foundation package version 4.2.6.

Install AR Core XR Plugin for Android.

Prepare resources: an image for detection, a dragon model, and a joystick pack.

Set up Unity project for Android platform with specific player settings.

Configure AR Core in the Android plugin management settings.

Create an AR scene by removing the main camera and adding XR components.

Add AR Tracked Image Manager to detect and spawn the dragon prefab.

Write a script to instantiate the dragon prefab when the image is detected.

Adjust dragon prefab size and animations for the AR experience.

Create and attach a Dragon Controller script for moving the dragon with a joystick.

Add a fixed joystick UI element to control the dragon's movement.

Build and run the AR application on an Android device.

Scan the prepared image with the app to spawn and control the dragon using the joystick.

Transcripts

play00:00

and by the end of this video you would

play00:02

have created an amazing air application

play00:03

wherein you can scan an image to spawn a

play00:06

dragon and move it around using a

play00:07

joystick and the best part is that

play00:09

you'll be able to develop this

play00:10

application in about 15 minutes so let's

play00:13

get started all right so to begin with

play00:14

you need to have your Unity software

play00:16

downloaded and installed so if you don't

play00:17

have it already then you can visit this

play00:19

website unity.com downloads and click on

play00:22

download for Windows now this is going

play00:23

to download the unity Hub software which

play00:25

is going to look something like this and

play00:27

it helps you manage all your projects

play00:28

and it helps you manage the different

play00:30

versions of editor that you have and for

play00:32

each of the editor it will let you add

play00:34

different modules that you need as per

play00:35

your requirement so once you have the

play00:37

unity Hub then you can scroll down so

play00:40

you find the link for download archive

play00:41

in the download archive you need to

play00:43

click on download LTS releases and

play00:45

that's because they don't have any bugs

play00:47

and even if they are their updates that

play00:49

Rectify them and the version that we're

play00:52

going to use is going to be

play00:54

2021.3.6 so make sure from the drop down

play00:56

you select 2021.3 and scroll all the way

play00:59

down till you find the version 6. now

play01:02

make sure to download this and I'm

play01:03

suggesting you to download the same

play01:04

version as me and that's because if you

play01:06

find any errors then it'll be easy for

play01:08

me to help you guys fix it

play01:11

now since I already have the editor it's

play01:12

saying that I have it so let's skip that

play01:14

part all right so once you have your

play01:16

editor installed then you can click on

play01:18

settings add modules and then you need

play01:20

to make sure that you have these three

play01:21

modules installed so the Android will

play01:23

support with Android SDK ndk tools and

play01:26

open jdk so you need to have these

play01:27

installed and once that's done you can

play01:30

go to projects and create a new project

play01:32

we'll uh from the drop down if you have

play01:34

different editor versions make sure

play01:35

you're using

play01:37

2021.3.6 we'll use the 3D core render

play01:40

pipeline we'll name our project as

play01:43

AR image tracking

play01:46

image

play01:48

tracking and click on create project all

play01:51

right so we have a Unity project open

play01:52

and the first thing that we need to do

play01:54

is download all the packages and

play01:55

resources that we'll be needing to

play01:57

create this AR application so let's go

play01:59

to Windows package manager and let's go

play02:02

to Unity registry here search for AR

play02:04

foundation so this is the one version

play02:07

4.2.6 click on install

play02:11

now along with this we need another

play02:13

package which is going to be the AR core

play02:15

so you can select the air core XR plugin

play02:17

and click on install once again

play02:19

foreign now let's go ahead and download

play02:22

all the resources that we need to create

play02:23

this application and the First Resource

play02:25

that we need is an image that can be

play02:27

detected so I'm using this particular

play02:28

image from Game of Thrones and then once

play02:30

the image is detected we need a model

play02:32

that has to be spawned for that I'm

play02:33

using this Dragon asset and finally once

play02:36

you have your model spawned you should

play02:38

be you should be able to move it around

play02:39

as well and to do that I'm using the

play02:41

joystick pack asset now I'll leave a

play02:43

link for all these three in the

play02:45

description below so you can also

play02:46

download the same all right so now that

play02:48

we have all the assets let's go ahead

play02:49

and import them into Unity so for that

play02:51

we'll go to Windows package manager and

play02:53

in here let's search for the dragon

play02:54

asset click on import

play03:03

next we'll go ahead and import the

play03:05

joystick pack as well

play03:11

and finally let's go ahead and import

play03:13

the image

play03:15

there we go

play03:17

so now it's time to set up our project

play03:19

so let's go to file build settings and

play03:21

the first thing to do here is to switch

play03:22

to Android platform

play03:29

so once that's done you can click on

play03:31

player settings and in the other

play03:33

settings make sure you uncheck

play03:34

autographics API select the welcome API

play03:36

and let's go ahead and remove that we

play03:38

need to uncheck multi-thread rendering

play03:40

and we'll scroll down make sure this is

play03:42

level 24.

play03:44

and here we need to change the scripting

play03:46

back end from mono to Il to CPP and here

play03:49

we got to make sure to check the arm 64.

play03:51

so these are the settings that you need

play03:53

to do in order to make sure that it runs

play03:55

on your Android device next we need to

play03:57

click on the AI plugin management make

play03:59

sure you're on the Android tab and in

play04:01

here check the AR core

play04:03

all right so with that we have set up

play04:04

our project now let's go ahead and set

play04:06

up ours now creating the scene is fairly

play04:08

simple first thing to do here is to get

play04:10

rid of the main camera and then right

play04:11

click select XR select air session

play04:13

origin now this game object comes along

play04:15

with ar camera and that's the reason why

play04:17

we got it of the main camera and then

play04:19

there's another game object that we need

play04:21

to add so to do that right click select

play04:23

XR once again and add AR session so once

play04:26

you have these two we'll select the AR

play04:27

session origin and add the component AR

play04:30

tracked image manager now this component

play04:32

basically uh tracks the image and once

play04:35

it's done it instantiates this prefab

play04:37

that we give but we're not going to do

play04:38

it that way we're just going to give it

play04:40

an image and then we'll write a separate

play04:41

script which will spawn the prefab once

play04:44

the image is detected so first thing to

play04:46

do here is to create the serialized

play04:48

library and image Library so we'll right

play04:50

click in the project window click on

play04:52

create go to XR and we'll select the

play04:54

image reference image Library

play04:56

and you can rename it if you like to but

play04:58

I'm going to leave it as it is I'll

play04:59

click on ADD image and let's add the

play05:01

image that we have imported here

play05:04

then select the air session origin and

play05:06

drag and drop the image reference

play05:08

library here next add a component we'll

play05:10

create a new script we'll call this as

play05:13

image Creator not image Creator we call

play05:16

it as prefab Creator so

play05:18

prefab creator

play05:21

there we go

play05:23

all right so here we are in visual

play05:25

Studios let's go ahead and get rid of

play05:26

this code over here and let's add the

play05:28

package that we'll be using so it's

play05:29

going to be using Unity engine

play05:33

Dot XR

play05:35

dot AR Foundation

play05:37

all right now let's declare all the

play05:39

variables that we need for the script

play05:40

the first one is going to be a

play05:42

serialized field

play05:43

private

play05:45

it's going to be of type game object and

play05:47

it's going to be the dragon prefab

play05:49

dragon

play05:51

prefab

play05:52

and next we need a vector 3 so let's

play05:55

make it our serialized field once again

play05:58

private

play05:59

Vector 3 and let's call it as prefab

play06:02

offset

play06:05

now I'll tell you why we need this once

play06:06

we go back into Unity but let's just

play06:09

continue in visual Studios for now

play06:11

next let's declare another variable

play06:13

which is going to be a private game

play06:14

object of and it's going to be called as

play06:17

dragon and this variable is basically

play06:20

going to store the instantiated prefab

play06:22

and finally we need a variable to store

play06:24

the Air Track image manager component so

play06:27

it's going to be ar

play06:29

tracked image manager we'll call it as

play06:32

Air Track image manager there we go now

play06:35

on enable so when it is enabled the

play06:38

first thing that we need to do is go

play06:39

ahead and get the aircraft image manager

play06:41

component so we'll assign it to this

play06:43

variable air attack image manager it's

play06:45

going to be equal to gameobject dot get

play06:47

component

play06:49

KR tract

play06:51

image manager

play06:53

there we go and then let's subscribe to

play06:55

its event on image changed when the

play06:57

attack image is changed so it's going to

play06:58

be ar

play06:59

attract image manager dot track images

play07:02

changed plus equal to on image

play07:08

on image changed and all you need to do

play07:11

is right click on this and go to Quick

play07:12

actions and generate a method so it's

play07:14

going to generate a method for us

play07:15

automatically it's going to be of

play07:16

parameter AR track images change event

play07:18

arcs I know that's long but it's the

play07:21

parameter that's there and it's going to

play07:22

have an OBG as the output that we get

play07:25

let's go ahead and get rid of this now

play07:27

in here we want to have for each so for

play07:30

each AR tracked image so for each of the

play07:33

tracked image let's go ahead and rename

play07:35

this as image in obj

play07:38

in this particular obj that we get Dot

play07:41

now when it is added for the first time

play07:43

okay so for each of the image inside

play07:45

this objection is added for the first

play07:47

time what we want to do is we want to

play07:48

instantiate the dragon prefab so and

play07:51

then store it inside the dragon variable

play07:52

as well so we're going to say it as

play07:54

dragon

play07:55

is going to be equal to instantiate

play07:59

the dragon prefab and in which location

play08:02

do we want it it should be above the

play08:04

image so we're going to call it as image

play08:05

dot transform there we go and then for

play08:08

some reason of course some it could be

play08:10

possible that any model that you're

play08:11

using might have some offset so in order

play08:14

to accommodate that we're going to call

play08:15

it we're gonna use Dragon dot transform

play08:19

dot position plus equal to the offset

play08:22

value that we have

play08:23

there we go and that that's and that's

play08:26

about it so let's go ahead and save this

play08:28

go back to Unity

play08:30

and let's wait for the script to load

play08:34

all right here we need to provide a

play08:35

dragon prefab so let's go ahead and make

play08:37

use of one of these Dragon prefab that

play08:39

we already have so we'll go in here

play08:40

we'll go to prefabs and I'm going to use

play08:42

the terror Binger and use the blue one

play08:44

so here you can see it's actually quite

play08:46

big and just to give you a reference

play08:48

we'll go ahead and create a cube of a

play08:50

meter size print at zero so you can see

play08:53

how big this dragon is so we need to

play08:54

reduce its scale so I'm going to reduce

play08:56

it to 0.015

play08:58

0.015 and 0.015 there we go

play09:02

now this cube is one one meter so for

play09:04

example if I wanted to be something like

play09:05

10 centimeter then this is how big is

play09:08

going to be let's reset its position so

play09:10

there we go so I think this is a good

play09:12

size to have but you can vary the size

play09:13

as per your requirement let's get rid of

play09:15

the cube here now this blue dragon uh

play09:18

will set this rotation to zero as well

play09:20

but if you see the AR camera right it's

play09:22

pointing in this particular direction so

play09:24

which means that when this object spawns

play09:26

it's going to look away from the camera

play09:27

so to so to change that we'll have this

play09:30

y as 180

play09:32

next this prefab also has a animator in

play09:36

place so let's go ahead and open that

play09:37

now here you can see there are so many

play09:39

animations that are there we don't want

play09:40

all of them so let's go ahead and get

play09:42

rid of these get rid of these now all we

play09:44

need is take off and fly forward so

play09:46

let's go ahead and get rid of these and

play09:48

this and this as well perfect now let's

play09:51

make a transition to here and from here

play09:53

to here so now if I go to scene and

play09:56

press play you can see that the dragon

play09:58

is just going to take off and then it's

play10:00

just gonna fly around in the same

play10:01

position

play10:02

perfect so we have our prefab ready

play10:04

let's go ahead and add that so we'll go

play10:07

back to here prefabs and here now before

play10:11

you get delete this particular one make

play10:12

sure to go to override and say apply all

play10:14

let's click on blue and make sure it's

play10:16

added so here you can see that the

play10:18

position and rotation is still the same

play10:19

so we'll make this 0 we'll make this as

play10:21

180. perfect now we can get rid of this

play10:24

select the AR system origin drag and

play10:27

drop the blue prefab inside the dragon

play10:29

prefab now talking about the offset so

play10:31

if I bring this back here and if I press

play10:33

play you can see that the dragon will

play10:35

start flying now when it flies

play10:37

and there's some offset and also even

play10:39

here the base there's some offset to its

play10:41

actual Center that's the reason why we

play10:43

have offset here so you can leave it at

play10:45

zero but um it's based on trial and

play10:48

testing so I felt the best one would be

play10:50

0.1 actually so this is the offset that

play10:52

I like so I'm going to get rid of this

play10:53

here again

play10:54

and that's pretty much it now there is

play10:57

one more script that we need so

play10:58

basically we want to be able to move the

play11:00

dragon around once it's spawned so to do

play11:02

that we'll select the dragon We'll add a

play11:04

component we'll create a new script

play11:06

we'll call it as

play11:07

Dragon controller

play11:10

and let's open this

play11:14

yeah and so let's open this and I'll see

play11:16

you in digital Studio all right so here

play11:18

we are in visual Studios let's go ahead

play11:19

and get rid of this code over here now

play11:21

the first thing that we need is our

play11:22

variable to store the speed so it's

play11:24

going to be serialized feed private load

play11:26

and we'll call it as speed and then we

play11:29

need uh two more variables our first

play11:31

variable is going to store the fixed

play11:32

joystick component and the second one is

play11:34

for the rigid body so let's go ahead and

play11:35

create a private

play11:37

fixed joystick here and we'll call it as

play11:40

fixed joystick and let's create another

play11:42

variable for the rigid body component

play11:45

there we go we call it as rigid poly now

play11:47

on enable so when it is enabled we want

play11:50

to get this particular component right

play11:52

away and so the rigid body as well I'm

play11:55

going to change this name I'm going to

play11:55

make the B capital there we go so fixed

play11:58

rigid uh so fixed joystick is going to

play12:00

be equal to

play12:02

find object of type where we want to be

play12:05

fixed joystick there we go so we have

play12:07

that component and we also need the

play12:08

digital body component so rigid body is

play12:11

going to be equal to game object Dot

play12:14

get component

play12:16

and let's get the rigid body component

play12:19

all right so once we have this in the

play12:20

fixed update so fixed update we want to

play12:24

move this right so to move it around

play12:25

first thing that we need to do is get

play12:27

the joysticks X and Y values so we'll

play12:29

have it as float

play12:32

float X well is going to be equal to

play12:36

the fixed joystick dot horizontal axis

play12:40

and the next one is going to be float

play12:43

y value is going to be equal to fixed

play12:46

joystick dot vertical all right once we

play12:49

have this then we can Define as to which

play12:50

way it has to be moving so first we'll

play12:52

have the moment which is going to be a

play12:53

vector 3 so Vector 3

play12:57

movement

play12:59

is going to be equal to

play13:01

new

play13:02

Vector 3 x well

play13:05

comma 0 we don't want the dragon to move

play13:07

up and down and then we'll finally say

play13:09

y1 so here we are converting the 2D

play13:11

access into moment along the x and z

play13:15

plane all right so once we have the

play13:16

moment we can make it move in that

play13:18

particular direction for that we'll make

play13:19

use of the Velocity uh property of rigid

play13:22

body component so we'll say rigidbody

play13:24

dot velocity is going to be equal to the

play13:28

moment times the speed

play13:30

perfect so now at this particular stage

play13:32

Your Dragon will be moving but it will

play13:33

not face the direction in which it has

play13:35

to move so in order to do that we'll say

play13:37

if the X Val is not equal to

play13:40

0 and

play13:42

the Y valve is also not equal to zero so

play13:46

only in this case we want to say

play13:48

transform dot Euler angle is going to be

play13:51

equal to Nu

play13:53

Vector 3 and here it's going to be

play13:56

the uh transform

play13:58

is going to be transform dot Euler angle

play14:01

dot X now if you think about it we want

play14:03

the dragon to rotate around the y-axis

play14:05

so which means that the rotation about x

play14:06

and z axis remains constant and does not

play14:08

change so we'll say transform dot Euler

play14:10

angles at X comma so for y we will use

play14:13

the math function so math f

play14:16

matter dot 8 and 2 and in here we'll

play14:19

pass in the X valve comma y Val

play14:25

there we go I think I'll scroll this

play14:26

slightly up here so that we can see as

play14:28

well and zoom out a bit okay so and then

play14:31

multiply this by math F dot gradient to

play14:34

degree and finally we'll take transform

play14:38

dot Euler angles dot Z

play14:41

yeah there we go so that's about it

play14:43

semicolon

play14:47

perfect so now with this script you

play14:49

should be able to move the player along

play14:50

so let's save it and go back to Unity

play14:53

all right so now let's add the joystick

play14:54

to our scene to do that you'll have to

play14:56

right click select UI select canvas next

play14:58

scroll down in the canvas scalar we'll

play15:00

change it from constant pixel size to

play15:02

scale uh scale with screen size and

play15:05

let's change this value so I think the

play15:06

best values to take would be something

play15:08

like this one so it's going to be

play15:11

2160 cross 1080 so this is like almost

play15:15

the standard size of all the modern

play15:16

smartphones that we have and then let's

play15:18

go to joystick pack prefabs then here we

play15:21

have the fixed joystick drag and drop it

play15:23

inside the canvas now you're able to see

play15:24

the joystick here so let's double click

play15:26

on it and I'm going to increase the

play15:28

scale to 2 so that is bigger and easy to

play15:30

use and probably more slightly above and

play15:33

towards the right here

play15:34

yeah I think so much is fine the low

play15:37

prefab has a size of 0.5 we have edited

play15:40

its uh animation and here we need to add

play15:42

two more components the first one is a

play15:44

rigid body make sure to uncheck use

play15:45

gravity and the next one is the dragon

play15:47

controller and here we'll set the speed

play15:49

to 0.5 and then let's go up here click

play15:52

on overrides and say apply all so that

play15:54

it gets applied to the prefab and let's

play15:56

go ahead and remove this so that's about

play15:57

it let's save the scene and let's now

play15:59

build it onto our device so to do that

play16:01

you will have to go to file build

play16:03

settings and then before you actually

play16:04

build it you need to connect your device

play16:06

to your laptop or to your PC so let's go

play16:09

ahead and do that all right so I've

play16:11

connected it you need to enable USB

play16:13

debugging mode so if you're not sure how

play16:14

that's done then I'll leave a link for

play16:15

that over here or in the description so

play16:18

you need to enable USB debugging so once

play16:20

that's done you'll let's refresh here

play16:22

and here you can be able to see your

play16:23

device minus one plus and then we'll say

play16:25

click on build and run we'll right click

play16:27

create a new folder we'll call it as

play16:29

builds

play16:31

we'll call it as bills there we go

play16:35

let's open it we'll call it as test

play16:37

Maybe

play16:39

foreign

play16:42

and it's going to take a while and I

play16:44

will see you once it's done building

play16:46

all right so here we have the

play16:47

application running let's go ahead and

play16:49

scan the image and once we have the

play16:52

image scan we get the dragon prefab and

play16:54

now we can use the joystick to move it

play16:56

around

play16:57

it's super cool and it's so much fun

play17:01

all right so this was a video to show

play17:02

you how quickly you can develop an AR

play17:04

application and you learned about image

play17:06

tracking now if you want to learn in

play17:07

depth and learn more about the

play17:09

foundation and its features then you

play17:11

should definitely check out this

play17:12

playlist over here wherein I talk in

play17:14

detail about each of the component and

play17:15

how phase tracking works and

play17:18

are all the different things related to

play17:20

AI Foundation all right I hope you

play17:22

enjoyed this video if you feel that you

play17:23

have learned something new then I'd

play17:25

highly appreciate it if you can leave a

play17:26

like And subscribe and as usual I will

play17:29

see you in the next one

Rate This

5.0 / 5 (0 votes)

Ähnliche Tags
AR DevelopmentUnity TutorialImage TrackingDragon ModelJoystick ControlMobile AppQuick ProjectGame DevelopmentAndroid StudioXR Technology
Benötigen Sie eine Zusammenfassung auf Englisch?