Great video and great series, if anyone is having trouble with their prefabs being placed halfway through the detected planes, try parenting your prefab to an empty, then 0 out all the transforms on both your prefab and empty, then adjust the y position of your prefab so that it rests above the ground grid. Hope this helps :)
Hi Samyam, I know you're done with Unity, but if I can just ask you a question it would really help me a lot. So, I understand tap and place, but what do you do if you just want your object to spawn automatically, right after the surface is detected? What steps do I take or omit, because every tutorial is about tap and place, and nothing on just detect and spawn without tapping. Thanks!
Great tutorial! I'm using the same technique but instead of instantiating a Prefab, I'm setting the transform of a single GameObject that already lies in the scene and turning on and off its meshrenderers because it has animations and other interactive functionality that needs to persist during the session. I have two questions: 1) I've seen other tutorials that use anchors. Do they offer any advantage over simply placing the object at the hit.pose with a plane? 2) How can I restart the AR experience? reloading the same scene using the SceneManager throws a bunch of errors. I've tried also using arSession.Reset(); LoaderUtility.Deinitialize(); SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex, LoadSceneMode.Single); LoaderUtility.Initialize(); but it still does not work.
Btw how can we instantiate objects randomly on the generated planes? For example if i want to instantiate just 5 objects anywhere in the detected planes.
Using the IDEs refactoring tools will generate the method signatures for you, so you don't have to type it out with all the required parameters (ex., FingerDown). This would save time and eliminate typing mistakes. Unfortunately, VS Code has very little to offer for C# refactoring extensions. :(
Hi Samyam, I'm new to this unity ..my friend and I have a project to make mapping in our campus..watched tutorial but it's the old version of unity so it's little complicated for me to know whether 3D project is more okay or AR project is more okay...which one should I choose 😢
thank you for this tutorial.. When tried in android the plane detected is keep on shaking.. and also on moving camera, the plane moves and offsets from the real world floor plane.. now both plane and prefab placed is in air at height of two feets.. is this ar core issue ?
Is there any way to test that in the simulation-mode of the editor with mouse clicks? The touch is recognized when i click but ARRaycastManager.Raycast never hits anything. When i test it on my android phone it works though. It is so tedious to test everything on the phone.
I copied your code exactly, but my object keeps spawning infinitely, and only in one place despite my tapping elsewhere. Any clue what may be going on?
Very nice and well explained 🙂. I have one odd problem.. If i run it on Android it works perfect, but on ios the alignment on first placed is good, but the rest gets the same orientation as the first one, eventhough it should be aligned towards you every time.. IOS feaure ?!?!
Hey, I keep getting an error stating "InvalidOperationException: EnhancedTouch API is not enabled; call EnhancedTouchSupport.Enable()" I have Input system installed and my code compiles with no errors. This error happens on runtime. Any help on this would be much appreciated!
You are supposed to call that Enable function before using the EnhancedTouchSupport as it suggests, else the input will not register. Call it in the OnEnable function
You can check if the tap is over a gameobject using IsPointerOverGameObject docs.unity3d.com/2018.2/Documentation/ScriptReference/EventSystems.EventSystem.IsPointerOverGameObject.html
@@samyam Thank you so much for the reply! Did you put IsPointerOverGameObject inside the FingerDown function or in the Update function like the documentation says. I tried putting an If(!EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId)) outside the foreach loop and it still registered the tap on the overworld.
Thanks for subscribing! You can write a simple boolean that turns true once you’ve clicked the first time, and then check that boolean later on, or deactivate the script entirely to prevent unnecessary checking.
Hi samyam, im learning from you so thanks so much for your effort. I tried to do the placement on tapping, but it didnt work for me for some reason 😭. I can see the plane but no objects are spawning when i click. I wonder what am i missing
If you have AR Foundation you can check the inspector/console (debug log) and see if the object is being spawned. It might be several things, so make sure to step through each statement and check if it’s getting executed correctly. We also have a Discord in the description where you can ask for help.
Hi, I'd like to instantiate a number of prefab randomly inside the surface of the ARPlane I clicked on. I tried it that way: private void InstantiateTarget(ARPlane plane) { Transform planeTransform = plane.gameObject.transform; Bounds planeBounds = plane.gameObject.GetComponent().mesh.bounds; for (int i = 0; i < _numberTarget; i++) { Vector3 position = GetRandomPosition(planeBounds, planeTransform); Instantiate(_prefab, position, Quaternion.identity); } } private Vector3 GetRandomPosition(Bounds planeBounds, Transform planeTransform) { float minX = planeTransform.position.x - planeTransform.localScale.x * planeBounds.size.x * 0.5f; float minZ = planeTransform.position.z - planeTransform.localScale.z * planeBounds.size.z * 0.5f; return new Vector3(Random.Range(minX, -minX), planeTransform.position.y, Random.Range(minZ, -minZ)); } But it doesn't work, how can I do it?
Wishlist my new game BUMBI on Steam! store.steampowered.com/app/2862470/BUMBI/
So grateful for all your work!❤
❤❤❤
Great video and great series, if anyone is having trouble with their prefabs being placed halfway through the detected planes, try parenting your prefab to an empty, then 0 out all the transforms on both your prefab and empty, then adjust the y position of your prefab so that it rests above the ground grid. Hope this helps :)
Mine does not spawn at all :/
very nice - thats what we like :)
Hi Samyam, I know you're done with Unity, but if I can just ask you a question it would really help me a lot. So, I understand tap and place, but what do you do if you just want your object to spawn automatically, right after the surface is detected? What steps do I take or omit, because every tutorial is about tap and place, and nothing on just detect and spawn without tapping. Thanks!
Great tutorial!
I'm using the same technique but instead of instantiating a Prefab, I'm setting the transform of a single GameObject that already lies in the scene and turning on and off its meshrenderers because it has animations and other interactive functionality that needs to persist during the session.
I have two questions:
1) I've seen other tutorials that use anchors. Do they offer any advantage over simply placing the object at the hit.pose with a plane?
2) How can I restart the AR experience? reloading the same scene using the SceneManager throws a bunch of errors.
I've tried also using
arSession.Reset();
LoaderUtility.Deinitialize();
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex, LoadSceneMode.Single);
LoaderUtility.Initialize();
but it still does not work.
Btw how can we instantiate objects randomly on the generated planes? For example if i want to instantiate just 5 objects anywhere in the detected planes.
Using the IDEs refactoring tools will generate the method signatures for you, so you don't have to type it out with all the required parameters (ex., FingerDown). This would save time and eliminate typing mistakes. Unfortunately, VS Code has very little to offer for C# refactoring extensions. :(
your really smart, where did you learn all this
how to set random color on each new object?
Hi Samyam, I'm new to this unity ..my friend and I have a project to make mapping in our campus..watched tutorial but it's the old version of unity so it's little complicated for me to know whether 3D project is more okay or AR project is more okay...which one should I choose 😢
I got error 'Meshing is not supported on this device' I think it doesn't support Android
thank you for this tutorial..
When tried in android the plane detected is keep on shaking..
and also on moving camera, the plane moves and offsets from the real world floor plane..
now both plane and prefab placed is in air at height of two feets.. is this ar core issue ?
What vscode extensions / linting are you using! I wish my IDE would be as helpful as yours looks.
I share them here! ruclips.net/video/3GVGyooZ8jk/видео.html
How to make AR sticker using unity please
Hi , do we need Arcore for building/ view AR apps in Android??? Can we do without ARcore??
i know it's a random question but what is the switch on your keyboard? it sounds so satisfying!
mechanical keyboard
Is there any way to test that in the simulation-mode of the editor with mouse clicks?
The touch is recognized when i click but ARRaycastManager.Raycast never hits anything.
When i test it on my android phone it works though.
It is so tedious to test everything on the phone.
I copied your code exactly, but my object keeps spawning infinitely, and only in one place despite my tapping elsewhere. Any clue what may be going on?
Very nice and well explained 🙂. I have one odd problem.. If i run it on Android it works perfect, but on ios the alignment on first placed is good, but the rest gets the same orientation as the first one, eventhough it should be aligned towards you every time.. IOS feaure ?!?!
Hey, I keep getting an error stating "InvalidOperationException: EnhancedTouch API is not enabled; call EnhancedTouchSupport.Enable()" I have Input system installed and my code compiles with no errors. This error happens on runtime. Any help on this would be much appreciated!
You are supposed to call that Enable function before using the EnhancedTouchSupport as it suggests, else the input will not register. Call it in the OnEnable function
Sorry @@samyam but I'm getting the same error and I don't get what you mean.
In onEnable put it before onFingerDown subscribe but in OnDisable put it after onFingerDown subscribe
I'm getting black screen as soon as I tap on the screen to place an object. Any solution?
I tried it for my AR project, on iOS everything works just fine but on Android it doesn't work. What would be the problem?
When I added a button, both the button and the place object are both called when touched. What would I do to only have the button be registered?
You can check if the tap is over a gameobject using IsPointerOverGameObject docs.unity3d.com/2018.2/Documentation/ScriptReference/EventSystems.EventSystem.IsPointerOverGameObject.html
@@samyam Thank you so much for the reply! Did you put IsPointerOverGameObject inside the FingerDown function or in the Update function like the documentation says. I tried putting an If(!EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId)) outside the foreach loop and it still registered the tap on the overworld.
Hi, just signed up to your Patreon. Do you have a script that places the object just once in the scene ??
Thanks for subscribing! You can write a simple boolean that turns true once you’ve clicked the first time, and then check that boolean later on, or deactivate the script entirely to prevent unnecessary checking.
@@samyamcan you put a detailed tutorial for that?
Which version of unity is this?
Крутооооооо!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Hi samyam, im learning from you so thanks so much for your effort.
I tried to do the placement on tapping, but it didnt work for me for some reason 😭.
I can see the plane but no objects are spawning when i click.
I wonder what am i missing
If you have AR Foundation you can check the inspector/console (debug log) and see if the object is being spawned. It might be several things, so make sure to step through each statement and check if it’s getting executed correctly. We also have a Discord in the description where you can ask for help.
Hi, I'd like to instantiate a number of prefab randomly inside the surface of the ARPlane I clicked on. I tried it that way:
private void InstantiateTarget(ARPlane plane)
{
Transform planeTransform = plane.gameObject.transform;
Bounds planeBounds = plane.gameObject.GetComponent().mesh.bounds;
for (int i = 0; i < _numberTarget; i++)
{
Vector3 position = GetRandomPosition(planeBounds, planeTransform);
Instantiate(_prefab, position, Quaternion.identity);
}
}
private Vector3 GetRandomPosition(Bounds planeBounds, Transform planeTransform)
{
float minX = planeTransform.position.x - planeTransform.localScale.x * planeBounds.size.x * 0.5f;
float minZ = planeTransform.position.z - planeTransform.localScale.z * planeBounds.size.z * 0.5f;
return new Vector3(Random.Range(minX, -minX), planeTransform.position.y, Random.Range(minZ, -minZ));
}
But it doesn't work, how can I do it?
Source Code for free please!!! 🥲🥲🥲