Get Started with AR Foundation in Unity - Beginner Friendly Tutorial 2023

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
today I'm going to introduce AR foundation and show you how to deploy a simple augmented reality app from Unity onto your phone so we'll be using unity's AR Foundation which is a package that lets you create augmented reality experiences for any platform and thank you to Unity for sponsoring this video so with ar Foundation you can build to Android Apple and hololens it's super simple to set up and they support a ton of features including plane detection image tracking object tracking face tracking body tracking Point clouds and the list can go on and on with augmented reality we can easily blend the real and virtual world commonly through a phone camera or a hmd which is a headset that you put on your head such as the hololens 2. as a high level overview with ar Foundation we have subsystems and providers Unity provides the subsystems which are essentially interface which contain functions that the providers have to implement on their end in this case the providers would be ar core for Android an AR kit or apple I like to think of interfaces as sort of a recipe of steps or functions that you follow or Implement and the providers themselves are the chefs with the ingredients that actually implement the functions or the steps listed in the recipe and then there are managers managers help these subsystem data be accessible in the unity scene through game objects so that implies that every subsystem has an equivalent manager for example if you have the XR plane subsystem and it detects a plane in the environment then the plane manager which accesses the subsystem data can create a game object in the scene representing that plane so to get started I recommend in the unity hub first starting with the AR new project temp template and this comes with the packages that we need already pre-installed as well as a sample scene we can just create that project additionally depending on if you want AR on Android or iOS you'll need to go to your installs folder in the unity Hub click the settings icon next to your version click add modules and if you're building to Android you need Android build support if you're building to iOS you need iOS build support and I do have two different videos each detailing how to build to both IOS and Android and once the project opens we'll see this pop up here which we can just close I'll show you how to do this if you already had an existing Unity project you can go to window package manager then under the unity registry tab you'll want to download AR Foundation right here you can click install and you want to download your plugin so if you're building to AR core or Android you need the AR core XR plugin if you're building to iOS you need the ark XR plugin and there's also the AR kit face tracking if you need face tracking in your project so go ahead and install those as needed and I also recommend installing the input system to use unity's latest version of the input which also comes installed with the AR template okay for settings go to filed build settings and you'll want to switch to the platform You're Building to which is either Android or iOS so we can switch the platform as so alright and once you've switched the platform I also like to enable development build so we don't have to configure any keys since we're just testing the app and that makes it easier for us to build to the phone with less setup then we go to player settings which you can also reach that through edit project settings so under the player settings if you're building to iOS you're going to want to scroll down and for iOS we need a minimum iOS Target version of 11.0 and if you need AR kit support or in your app if it's required you need to also check requires AR kit support and this little warning goes away if you just type in the version number again and we'll also want to add a bundle identifier which is how our app is identified on the phone which is com dot your company name which I'm just going to put samyam and then the name of your app.app which can be changed later and that's basically settings for iOS for Android I do not have AR core on my phone however we'll also need to add a package name here and then you want a minimum API level of 24 if you require AR in your app if not the minimum API level you will need is 19. you'll also want to uncheck Auto Graphics API if that's checked and if you have Vulcan in the graphics apis you're going to want to select it and remove it since it does not currently support that and lastly you want to make sure you have il-2 CPP as the scripting back end during development you can can put it to mono and you can select arm B7 which is a 32-bit architecture as well as the 64-bit however when you ship to the Play Store you'll need il-2 CPP and you'll need to enable both the arm V7 and arm 64. Google has their own guide on how to do this so I recommend following that for more details alright so you're going to want to go in the player settings to the XR plug-in management and this is the area where the providers are located and you'll want to enable the providers that you're going to be using in the case of Android you'd go to the little Android tab here and click on AR core and in the case of iOS you'd go and click a r kit and it will now install the AR kit package into the unity project and once that's installed you should see the check mark pop up and to confirm you can go into the settings under the XR plugin management here AR kit and you'll see that there are some settings that you can change so for the requirement we do want it to be required in this case because our app will be fully AR and then you can also enable face tracking here if you need it and with ar core there are some settings as well but usually you want to keep them as default okay once that's set up make sure you're in the sample scene under scenes blank AR and if not you can easily add these components to empty game objects you'll see that it also comes with a little tutorial tab here for more information but I'll just close this for now so there's a couple main components here that we want to pay attention to and these are going to be mandatory so we're going to want to make an empty game object called AR session and you want to add the AR session component which you can just add a component and call this AR session and add that to this game object and this basically manages the life cycle of the AR app and so if you disable this AR will no longer work in this game so you want to make sure this is added and enabled as this helps keep track of all the other subsystems in the AR session the AR our input manager helps manage your input anytime you interact with the augmented reality scene the input manager is reading that input so that you can interact with objects such as planes on your scene then we have an AR session origin game object which you want to attach the AR session origin script to it and we'll want to pass in an AR camera so if you have a main camera you can just delete that and you'll want to create an AR camera which is basically a normal camera with a solid color and a black background so no Skybox and it has an AR camera manager an AR camera background and a tracked pose driver component added to the game object so as the name States the AR camera manager manages the camera of your phone and you can change several settings here such as the direction that you want it to be facing whether it's the world or the user the light estimation mode and if you want it to autofocus now for all of these settings we'll want to keep the these as is for now and the tracked pose driver essentially applies the pose value of your phone to the transform of the game object so the camera and the unity scene will move as you move your phone around your room or the scene in the AR session origin is responsible for converting the AR session space into the unity World space so when we are using augmented reality on the phone we actually have a different coordinate system and that's called the AR session space and that needs to be converted into Unity World coordinates to correctly map the game objects into your AR session and you're going to want to position things in your Unity scene according to where your AR camera is located so for example if you want something to appear in front of your AR camera then we can add a empty 3D object we can add a little Cube here and you'll see it's right on our camera and so this will be our starting camera position in augmented reality so we'd want to actually move this box a little forwards so that the Box can spawn in front of us when we open our augmented reality scene as you see the forward Vector is the blue arrow here and so now the Box will be positioned correctly and this is very important to have this here especially for plane detection as planes are relative to the starting position of your device okay and so now we have the basics of our AR app here and we can just build this to the phone now if you go to file build settings and make sure you're on your correct platform then add your open scene click build I make a new folder here called builds then I press select and now it'll start to build the scene into our build folder in my case it will now open up xcode because I'm in iOS and from there I can build to my phone and so you'll want to connect your phone to your computer and make sure your phone phone is ready for development mode so if you don't have development mode enabled on your phone then I have a tutorial you'd want to follow on how to do that and how to build to Android or iOS in the description below okay now that it's done building we can go into the builds folder and if it didn't launch you can just click the xcode project there in the case of Android it will just build directly to your phone you'd want to select your device under run device if it doesn't show up that means there's something wrong and it's not detecting your phone and I'm just going to press play here so that it builds to my phone now that I've connected it to my computer but first I need to go into signing and capabilities automatically manage signing enable automatic and select my team that I've created already once again I go through that in my other tutorial and so once that's done the AR app should open up automatically and if you're on Apple you're going to want to press the OK here for the app to have access to your camera and you'll see we have the cube now on on our scene which is pretty cool and there's my dog alright so that's basically it one more thing I want to call attention to is that Unity has some sample projects for AR Foundation which you can go on their GitHub page Link in description and you can actually download this so if you go to the code and click download zip right here and you'll want to have version 2021.2 and above of unity as they say here and once you have that downloaded you can unzip the file and you'll have the unity project here which you can then go into Unity Hub click open search for your project here and click open I already have mine open if you go into the scenes here you'll see that now they have examples for every feature that they support which is super useful if you don't know how to do something specific you can just check here let's say you want to do image tracking then you can do a basic image tracking and they already have a scene set up for that along with scripts written in which is really useful and so this is the first tutorial of the small mini AR Series so I'll be doing some other tutorials on AR so keep an eye out for them and thank you again to Unity for sponsoring this video and thank you to my patrons for their amazing support as always if you're interested the link is in the description be sure to join our Discord as well thank you so much for watching and I'll see you next time thank you
Info
Channel: samyam
Views: 26,497
Rating: undefined out of 5
Keywords: unity beginner tutorials, samyam, unity engine, ar game, ar foundation, unity ar, ar in unity, ar foundation unity, dynamic navmesh, unity ar foundation, unity arcore, unity arkit, unity ior, unity ar game, Getting Started With ARFoundation in Unity, ar foundation subsystem, subsystems, managers, providers, ar foundation managers, ar foundation subsystems, ar foundation set up, ar foundation providers, beginner ar foundation, ar foundation basics, unity augmented reality
Id: FWyTf3USDCQ
Channel Id: undefined
Length: 12min 28sec (748 seconds)
Published: Fri Dec 23 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.