Beginners guide to UNITY AR Image Tracking | No code required | Build your first AR app from scratch

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi welcome back to my channel today we are going to look into how to use a marker or a picture to scan and spawn a game object through it as you see on your screen as you see a spider spawned on this spiderman's picture and is doing a little jump animation this is a beginner's video and if you're new like and like what you see hit the like button and please subscribe let's get started in unity hub first let us create a new unity project in the version 2020.1 i'll call it ar image tracking so this is the project i'll quickly adjust the width and height of the game display to make it a portrait [Music] so now as the project is initially created for pc i'll switch it to android you can switch it to ios as well if you're building for apple devices click on the platform in my case android and press switch platform now we need to import certain packages so i'll find the package manager tab just in case you don't have this window visible simply click on the window on the top ribbon and there you'll see package manager a tab will be added like mine if there wasn't any package manager tab initially so here in the package manager window if you see the small arrow on the top you'll get these options as unity registry which is all the packages that unity offers then in project which means all projects currently present in our project and others for this video we'll go to unity registry now we need to find out required packages so if you try to find ar foundation click on the down arrow on the left and see other versions try to locate version 3.1.6 expand the window and you can see the install button click install so that's done now for the android devices we'll install ar core so click on see other versions and search for version 3.1.8 click install and now on the for the ios devices we'll install ar kit so click on see other versions and search for 3.1.8 click install please remember to stick to these versions to work it's more like a combination lock sometimes with unity not all versions work with each other so the versions which are reliable to work have been installed by us now press the scene tab on the top to see the scene view and adjust the game window better now in the hierarchy on the left of the screen you see a game object called main camera delete that as we will be using a pre-built ar camera that came with the packages we just imported now placing your cursor in the hierarchy window right click and select xr ar session this is the most fundamental component of the ar scene then again right click and select xr ar session origin as you see on your right ar session has two default scripts on them and ar session origin has a script and which has a camera in it that's the ar camera as child to the ar session origin game object the camera has the necessary scripts on it to work now on the ai sachin origin game object in the hierarchy select that on the right in the inspector panel click add component type ar tract and select this ar tracked image manager this will configure what images to take in and what model should show up when the camera looks at an image in the bottom in the projects tab next to the two folders scenes and xr right click and hover over create and folder call it prefab double click to enter and again right click then xr right at the bottom and reference image library hit enter to keep the same name if you click on this new file you see in the right panel there is a button called add image click that and you see input fields for a texture name and specify size boxes so to add an image i'll create a folder in the assets folder and call it texture i'll just drag and drop the spiderman picture i took from the internet now going back to the prefab folder and single click reference image library file we'll select spiderman image by clicking select in the box and choose our image the name populates automatically however i'll specify the size as 0.1 meters by 0.1 meters and i wish to keep it the texture at runtime so take this checkbox now save scene and go to ar session in the hierarchy and you can see again the ar tracked image manager script on it in the serialized library you can drag and drop the reference image library file in the prefab folder we just created so that's been taken care of now the maximum number of moving images i'll just keep it one just to keep things simple then now we need to track we need a tracked image prefab so let's get something interesting here so what i'll what i'll do is go on the asset store tab and click search online here in the asset store search for a free spider so the spider called animated spider download by clicking on this blue button open in unity in my case because i already did once in your case it might say add to my assets go back to unity it should automatically show up now expand the window and import the asset by clicking import and then import again now let's go and check the spider in assets go to pb spider models drag the spider in the hierarchy we'll adjust a few things in the transform section on the right change the scale to 0.015 in x y and z double click on the spider to zoom in now if you see the spider in the bottom window it has an arrow click to expand and see what happens as you see it it's got a few mesh files and also the animation files including the jump file which you saw in the beginning so here you can see the preview now extract this jump animation by pressing command d for mac or control d for windows now for making this jump animation work a quick way is to right click in the bottom window here and select create and then animate a controller call it spydercontroller select the spider and drag the spider controller in the controller field now select the animation animator window if you don't see click on the windows animation and animator here in the animator window drag the jump animation and then the entry state will snap to the jump animation automatically this is a real quick way to do it then click on the jump animation and toggle this loop time checked on the spider so that it loops through the jump animation now that's it let's make the spider prefab so that we can use it anywhere in our project drag the spider and click original prefab now delete the spyder game object from the hierarchy as we have saved the prefab select the ar session origin game object in the hierarchy and drag this new spider prefab in the tracked image prefab section of ar tracked image manager i think that's it save scene and click on file build settings add open scene click player settings and then go to resolution and presentation select portrait then try to build by click file build settings and build and run one minute uh a few things for ar to work on android you need to a minimum api level of android 7 so select that then also in the graphic apis remove vulkan by selecting vulcan and clicking this minus sign now go to build settings and build and run there it is as you see i have a spider-man image and the spider is spawned on the image even if i move the ipad this is how you can create a little ai experience without writing any code that's it for today if you like my work give it a thumbs up subscribe as i'll be posting unity related videos possibly every week and don't forget to hit the bell icon thank you and peace
Info
Channel: Mohd Hamza
Views: 37,039
Rating: undefined out of 5
Keywords: augmented reality, unity tutorial, augmented reality tutorial, augmented reality tutorial for beginners, game dev, game development, unity3d game tutorial, ar tutorials, ar image recognition, coding for beginners unity
Id: OwpRSF7X9sI
Channel Id: undefined
Length: 10min 7sec (607 seconds)
Published: Sat Mar 20 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.