Problem solved! In Unity go to your project folder > Settings > URP-Balanced-Renderer. In the inspector click add renderer feature > set Ar Background Renderer Feature. Do the same with URP-HighFidelity-Renderer and be happy!
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)
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
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
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.
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.
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 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
@@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.
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
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
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; } }
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 :)))
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
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.
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 :)
@@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 =(((((((
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?
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.
Helpful video, thank you. Would be cool to have more videos, for example about meshing...
Thank you for sharing this info, looking forward for next video 🔥
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.
thanks for the details
hi im having black screen issue in the unity 2022.3.45f1, no camera view, onl;y the scene view is visible why?
Same problem
Problem solved! In Unity go to your project folder > Settings > URP-Balanced-Renderer. In the inspector click add renderer feature > set Ar Background Renderer Feature.
Do the same with URP-HighFidelity-Renderer and be happy!
@@dodikmanthank you so much😃
Just wanted to thank you for your effort 🫡
Thanks!!
is there a way to remove the orangeish part that spawns on the plane??
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)
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
hello xiena, i have some error on my unity. i dont have asset folder xr environment view manager. can u help me? thankyouu🙏🏻
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
Thank you
Thank you...
how do I replace game object with the 3d model that I've created?
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.
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.
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.
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?
Hi, please check if your device is in the supported list developers.google.com/ar/devices
@@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
@@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.
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
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
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;
}
}
Make more video please ! Thank you !
I will, thank you!
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 :)))
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
Hey Xienna, thank you for the tutorial!
Sadly my phone did not support AR Core, are there any alternative for it?
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.
Is there a way to tap and place a 2D image?
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?
I do this and my phone can find plane but no camera,all I can see is sky not real world, please help me
Hi, can you contact me via email at xiennastudio@gmail.com or on Discord at @xiennastudio
where is the video about xr simulation?
Hi, the XR Simulation video is not out yet, but it will be released within the next few days.
Hi, the XR Simulation video is out now 😄th-cam.com/video/LMtKRlR_EMQ/w-d-xo.html
idk how to create touchcontroll, can u help me =(((((
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 :)
@@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 =(((((((
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?
Hello!! Any ideas why my prefab takes up the whole screen?
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.
@@xiennastudio but why does it happen if i followed the same steps as you?
Is your prefab scale is set the same as in the video? In 01:54 I set the scale to 0.1@@IberianInteractive