Tap to Place Objects using AR Foundation 5 Unity 2023 with XR Origin & AR Session

แชร์
ฝัง
  • เผยแพร่เมื่อ 24 ต.ค. 2024

ความคิดเห็น • 47

  • @vitaliilohvynenko9265
    @vitaliilohvynenko9265 9 วันที่ผ่านมา

    Helpful video, thank you. Would be cool to have more videos, for example about meshing...

  • @mdrafi9074
    @mdrafi9074 3 หลายเดือนก่อน

    thanks for the details

  • @christopheradiprayoga623
    @christopheradiprayoga623 ปีที่แล้ว

    Thank you for sharing this info, looking forward for next video 🔥

  • @noorain8259
    @noorain8259 11 หลายเดือนก่อน

    Good work! Keep it up. Make more videos. Create video on object detection and pop up message appearance about object name on the object detection.

  • @nutvers1.0n
    @nutvers1.0n 3 หลายเดือนก่อน

    Thank you

  • @Shorkiedokey
    @Shorkiedokey 2 หลายเดือนก่อน

    Thanks!!

  • @suesuweni286
    @suesuweni286 ปีที่แล้ว

    Make more video please ! Thank you !

  • @galindoxrafa
    @galindoxrafa ปีที่แล้ว

    Great video!!! It Helped me a lot as the XR Origin is new and there's few tutorials. One question, how could you add a second gesture, for instance with 2 fingers rotate the Object. Thank you

    • @xiennastudio
      @xiennastudio  ปีที่แล้ว

      Glad it helped! I plan on creating a video about rotating and scaling the model using touch gestures. I will add the script to this comment first. You will need to use EnhancedTouch for this docs.unity3d.com/Packages/com.unity.inputsystem@1.7/manual/Touch.html#enhancedtouchtouch-class

    • @xiennastudio
      @xiennastudio  ปีที่แล้ว +1

      Hi, here is the script for 2 fingers to rotate the object. If there is any issue please tell me.
      using System.Collections.Generic;
      using UnityEngine;
      using UnityEngine.XR.ARFoundation;
      using UnityEngine.XR.ARSubsystems;
      using UnityEngine.InputSystem.EnhancedTouch;
      using Touch = UnityEngine.InputSystem.EnhancedTouch.Touch;
      [RequireComponent(typeof(ARRaycastManager))]
      public class PlaceOnPlaneRotate : MonoBehaviour
      {
      [SerializeField]
      [Tooltip("Instantiates this prefab on a plane at the touch location.")]
      GameObject placedPrefab;
      ///
      /// The instantiated object.
      ///
      GameObject spawnedObject;
      public float minTurnAngle = 0;
      public float pinchRatio = 1;
      ARRaycastManager aRRaycastManager;
      List hits = new List();
      void Awake()
      {
      aRRaycastManager = GetComponent();
      }
      private void OnEnable()
      {
      TouchSimulation.Enable();
      EnhancedTouchSupport.Enable();
      }
      private void OnDisable()
      {
      TouchSimulation.Disable();
      EnhancedTouchSupport.Disable();
      }
      void Update()
      {
      int touchCount = Touch.activeTouches.Count;
      // If one finger touch the screen.
      if (touchCount == 1)
      {
      Touch touchZero = Touch.activeTouches[0];
      // Check if the raycast hit any trackables.
      if (aRRaycastManager.Raycast(touchZero.screenPosition, hits, TrackableType.PlaneWithinPolygon))
      {
      // Raycast hits are sorted by distance, so the first hit means the closest.
      var hitPose = hits[0].pose;
      // Check if there is already spawned object. If there is none, instantiated the prefab.
      if (spawnedObject == null)
      {
      spawnedObject = Instantiate(placedPrefab, hitPose.position, hitPose.rotation);
      }
      else
      {
      // Change the spawned object position and rotation to the touch position.
      spawnedObject.transform.position = hitPose.position;
      spawnedObject.transform.rotation = hitPose.rotation;
      }
      }
      }
      // Rotate
      // If two fingers touch the screen at the same time.
      else if (touchCount == 2)
      {
      // If no spawnedObject, don't do anything.
      if (spawnedObject == null)
      return;
      Touch touchZero = Touch.activeTouches[0];
      Vector2 touchZeroPos = touchZero.screenPosition;
      Touch touchOne = Touch.activeTouches[1];
      Vector2 touchOnePos = touchOne.screenPosition;
      // Check the delta angle between them.
      // Get the angle between the two touch points.
      float turnAngle = GetAngle(touchZeroPos, touchOnePos);
      float prevTurn = GetAngle(touchZeroPos - touchZero.delta, touchOnePos - touchOne.delta);
      // Get the delta of the angle between the two touch points.
      float turnAngleDelta = Mathf.DeltaAngle(prevTurn, turnAngle);
      // If it's greater than a minimum threshold, it's a turn.
      if (Mathf.Abs(turnAngleDelta) > minTurnAngle)
      {
      Vector3 rotationDeg = Vector3.zero;
      rotationDeg.y = -turnAngleDelta;
      spawnedObject.transform.rotation *= Quaternion.Euler(rotationDeg);
      }
      }
      }
      private float GetAngle(Vector2 pos1, Vector2 pos2)
      {
      Vector2 from = pos2 - pos1;
      Vector2 to = new Vector2(1, 0);
      float result = Vector2.Angle(from, to);
      Vector3 cross = Vector3.Cross(from, to);
      if (cross.z > 0)
      {
      result = 360f - result;
      }
      return result;
      }
      }

  • @rubz5706
    @rubz5706 ปีที่แล้ว

    Thank you...

  • @alpharhomedia9006
    @alpharhomedia9006 10 หลายเดือนก่อน

    great tutorial, its very clear.
    I have follow all your instruction ( i guess ) but after i build to my android its just show black screen, what should I do?

    • @xiennastudio
      @xiennastudio  10 หลายเดือนก่อน

      Hi, please check if your device is in the supported list developers.google.com/ar/devices

    • @alpharhomedia9006
      @alpharhomedia9006 10 หลายเดือนก่อน

      @@xiennastudio
      thanks for the reply, sorry for missing this detil, yes my android phone is listed, also support depth API, digging for answr in the internet, I found to turn the camera backgorund, but there is no turn off camera background option in my Unity only background color picker

    • @xiennastudio
      @xiennastudio  10 หลายเดือนก่อน

      @@alpharhomedia9006 Try to check if the app has the necessary camera permissions in your phone settings. In Unity, make sure there is no issue in the Project Validation.

  • @maheshp2048
    @maheshp2048 19 วันที่ผ่านมา

    hi im having black screen issue in the unity 2022.3.45f1, no camera view, onl;y the scene view is visible why?

  • @aryanaggarwal6124
    @aryanaggarwal6124 7 หลายเดือนก่อน

    is there a way to remove the orangeish part that spawns on the plane??

  • @cgmoussalli
    @cgmoussalli 5 หลายเดือนก่อน

    Just wanted to thank you for your effort 🫡

  • @AmirhosseinRabei
    @AmirhosseinRabei 4 หลายเดือนก่อน

    I have follow all your instruction but after i build to my android its just show black screen too,and my phones camera not openning. what should I do?(my phone supports ar core)

    • @drizzy6087
      @drizzy6087 3 หลายเดือนก่อน

      ur phone doesnt have ARCore, it is not supported on your phone brother, if you cant find google depth in your play store then the arcore built in feature is not available on your phone

  • @noupo
    @noupo ปีที่แล้ว

    Hey Xienna, thank you for the tutorial!
    Sadly my phone did not support AR Core, are there any alternative for it?

    • @xiennastudio
      @xiennastudio  ปีที่แล้ว

      Hi, thank you for watching! I am not really sure about alternative. I think you can use EasyAR, Vuforia, or Wikitude, but you need to pay to use their SDK. I am not able to find any free alternative.

  • @nadilahhasfahani7405
    @nadilahhasfahani7405 10 หลายเดือนก่อน

    hello xiena, i have some error on my unity. i dont have asset folder xr environment view manager. can u help me? thankyouu🙏🏻

    • @xiennastudio
      @xiennastudio  10 หลายเดือนก่อน

      Hi, have you added XR Simulation to your project? If you haven't, you can check my other video on how to do it th-cam.com/video/LMtKRlR_EMQ/w-d-xo.html

  • @lingeleora6212
    @lingeleora6212 4 หลายเดือนก่อน

    how do I replace game object with the 3d model that I've created?

    • @xiennastudio
      @xiennastudio  4 หลายเดือนก่อน

      Sorry for the late reply. It's the same as in the video 01:42, but instead of creating a new cube, use the 3D model that you have.

  • @rubz5706
    @rubz5706 ปีที่แล้ว

    It's working fine on my XR simulation but when I build it on my android phone thing opens fine but it's not detecting any plane and tap to place is not working any solutions for this.

    • @xiennastudio
      @xiennastudio  ปีที่แล้ว

      Hi, may I know which Android phone you are using? Have you tried it on different phones or different locations? Your environment may not be suitable for plane detection. ARCore plane detection is not really good at detecting reflective surfaces, complex backgrounds, and low light conditions. Make sure that your environment is well-lit and free of reflective surfaces.

  • @nainamkumar
    @nainamkumar ปีที่แล้ว

    I keep getting an error saying: Cannot add script. The script is and editor script when I try to add the TouchControls script to my Game Object. The script is not in the editor folder and I followed all the steps in the end for using the new input with the editor to create the script. Please help me :)))

    • @xiennastudio
      @xiennastudio  ปีที่แล้ว +1

      Hi, the TouchControls script shouldn't be added to any game object. You should add any PlaceOnPlane script to the XR Origin game object. You can download all the scripts in my video here: www.patreon.com/posts/87675816

  • @nainamkumar
    @nainamkumar 11 หลายเดือนก่อน

    Is there a way to tap and place a 2D image?

    • @xiennastudio
      @xiennastudio  11 หลายเดือนก่อน

      2D image should be the same, just need to use Canvas world space in the AR Prefab instead of a cube. Is there any issue you are facing?

  • @宣成金
    @宣成金 ปีที่แล้ว

    where is the video about xr simulation?

    • @xiennastudio
      @xiennastudio  ปีที่แล้ว +2

      Hi, the XR Simulation video is not out yet, but it will be released within the next few days.

    • @xiennastudio
      @xiennastudio  ปีที่แล้ว +2

      Hi, the XR Simulation video is out now 😄th-cam.com/video/LMtKRlR_EMQ/w-d-xo.html

  • @峰碩張-k2s
    @峰碩張-k2s 11 หลายเดือนก่อน

    I do this and my phone can find plane but no camera,all I can see is sky not real world, please help me

    • @xiennastudio
      @xiennastudio  11 หลายเดือนก่อน

      Hi, can you contact me via email at xiennastudio@gmail.com or on Discord at @xiennastudio

  • @gialong1239
    @gialong1239 ปีที่แล้ว

    idk how to create touchcontroll, can u help me =(((((

    • @xiennastudio
      @xiennastudio  ปีที่แล้ว +1

      Hi, I explain about how to create Touch Control in this part 11:26. Remember to install Input System from Package Manager, and enable the Active Input Handling in Player settings to Both (06:32). Please tell me if you still have any issue :)

    • @gialong1239
      @gialong1239 ปีที่แล้ว

      @@xiennastudio hi....now i have a warning like this:
      "Saving has no effect. Your class 'UnityEditor.XR.Simulation.XREnvironmentViewManager' is missing the FilePathAttribute. Use this attribute to specify where to save your ScriptableSingleton.
      Only call Save() and use this attribute if you want your state to survive between sessions of Unity.
      UnityEditor.XR.Simulation.XREnvironmentViewManager:OnDisable () (at ./Library/PackageCache/com.unity.xr.arfoundation@5.0.7/Editor/Simulation/XREnvironmentViewManager.cs:169)"
      and my simulator can't work....sorry, this is my first time with unity and AR =(((((((

    • @xiennastudio
      @xiennastudio  ปีที่แล้ว +1

      Hi, I'm sorry, I just noticed your comment. If you still have the issue, may I know the step-by-step that you did before getting this error? Did you follow my Basic Setup video or do you use the Unity AR template or you already have the project?

  • @IberianInteractive
    @IberianInteractive 10 หลายเดือนก่อน

    Hello!! Any ideas why my prefab takes up the whole screen?

    • @xiennastudio
      @xiennastudio  10 หลายเดือนก่อน +1

      Hi! By takes up the whole screen do you mean it's so big that it's covering your screen? If that's true, tried to change the prefab scale to be smaller.

    • @IberianInteractive
      @IberianInteractive 10 หลายเดือนก่อน

      @@xiennastudio but why does it happen if i followed the same steps as you?

    • @xiennastudio
      @xiennastudio  10 หลายเดือนก่อน

      Is your prefab scale is set the same as in the video? In 01:54 I set the scale to 0.1@@IberianInteractive