Tap to Place Objects in Unity's AR Foundation - Tutorial 2023

Поделиться
HTML-код
  • Опубликовано: 26 янв 2025

Комментарии • 42

  • @samyam
    @samyam  10 месяцев назад +2

    Wishlist my new game BUMBI on Steam! store.steampowered.com/app/2862470/BUMBI/

  • @unity
    @unity 2 года назад +37

    So grateful for all your work!❤

    • @samyam
      @samyam  2 года назад +4

      ❤❤❤

  • @emmet3690
    @emmet3690 Год назад +2

    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 :)

    • @Sohneg
      @Sohneg 4 месяца назад

      Mine does not spawn at all :/

  • @chriswatts3697
    @chriswatts3697 2 года назад +1

    very nice - thats what we like :)

  • @WalrusesAreTheOne
    @WalrusesAreTheOne Год назад +1

    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!

  • @michelesandroni
    @michelesandroni Год назад +3

    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.

  • @invalidusername9490
    @invalidusername9490 5 дней назад

    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.

  • @badscotsman
    @badscotsman 2 года назад +1

    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. :(

  • @ChristopherRozarioiceboul
    @ChristopherRozarioiceboul Год назад

    your really smart, where did you learn all this

  • @vindereynetis3985
    @vindereynetis3985 8 месяцев назад

    how to set random color on each new object?

  • @shmall_potato
    @shmall_potato 4 месяца назад

    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 😢

  • @eunsoolee4855
    @eunsoolee4855 Год назад +1

    I got error 'Meshing is not supported on this device' I think it doesn't support Android

  • @Paruthi.618
    @Paruthi.618 Год назад

    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 ?

  • @MrWhatthemonkey
    @MrWhatthemonkey 2 года назад +1

    What vscode extensions / linting are you using! I wish my IDE would be as helpful as yours looks.

    • @samyam
      @samyam  Год назад +1

      I share them here! ruclips.net/video/3GVGyooZ8jk/видео.html

  • @switchRetroo
    @switchRetroo 7 месяцев назад

    How to make AR sticker using unity please

  • @ramkishorreddy3686
    @ramkishorreddy3686 Год назад

    Hi , do we need Arcore for building/ view AR apps in Android??? Can we do without ARcore??

  • @igorprado5909
    @igorprado5909 Год назад

    i know it's a random question but what is the switch on your keyboard? it sounds so satisfying!

  • @christianb.4637
    @christianb.4637 Год назад

    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.

  • @HilaryTsaiRageVlog
    @HilaryTsaiRageVlog Год назад

    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?

  • @sorenmuller1974
    @sorenmuller1974 Год назад

    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 ?!?!

  • @PavusthePug
    @PavusthePug Год назад +1

    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!

    • @samyam
      @samyam  Год назад

      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

    • @einnerlink
      @einnerlink Год назад

      Sorry @@samyam but I'm getting the same error and I don't get what you mean.

    • @AliAhmed-wc2bi
      @AliAhmed-wc2bi Год назад

      In onEnable put it before onFingerDown subscribe but in OnDisable put it after onFingerDown subscribe

  • @pratikmane566
    @pratikmane566 Год назад

    I'm getting black screen as soon as I tap on the screen to place an object. Any solution?

  • @azinshafiyan9829
    @azinshafiyan9829 Год назад

    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?

  • @williamlee9374
    @williamlee9374 Год назад

    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?

    • @samyam
      @samyam  Год назад

      You can check if the tap is over a gameobject using IsPointerOverGameObject docs.unity3d.com/2018.2/Documentation/ScriptReference/EventSystems.EventSystem.IsPointerOverGameObject.html

    • @williamlee9374
      @williamlee9374 Год назад

      @@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.

  • @nickdunn9090
    @nickdunn9090 Год назад

    Hi, just signed up to your Patreon. Do you have a script that places the object just once in the scene ??

    • @samyam
      @samyam  Год назад +1

      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.

    • @blobcat6237
      @blobcat6237 Год назад

      ​@@samyamcan you put a detailed tutorial for that?

  • @ngsoohao3624
    @ngsoohao3624 Год назад

    Which version of unity is this?

  • @Killua_uwu537
    @Killua_uwu537 Год назад

    Крутооооооо!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • @a7mdbest15
    @a7mdbest15 Год назад

    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

    • @samyam
      @samyam  Год назад

      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.

  • @AlexRonai
    @AlexRonai Год назад

    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?

  • @vitoScaletta0
    @vitoScaletta0 Год назад +5

    Source Code for free please!!! 🥲🥲🥲