एआर फ़ाउंडेशन के लिए झटपट प्लेसमेंट डेवलपर गाइड
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
अपने ऐप्लिकेशन में,
Instant Placement API या
परसिस्टेंट रेकास्ट का इस्तेमाल करने का तरीका जानें.
ज़रूरी शर्तें
आगे बढ़ने से पहले, पक्का करें कि आपने एआर के बुनियादी कॉन्सेप्ट और ARCore सेशन को कॉन्फ़िगर करने का तरीका समझ लिया हो.
कॉन्सेप्ट के नाम
AR Foundation और Unity के लिए ARCore SDK टूल के बीच, कुछ कॉन्सेप्ट और तरीकों के नाम अलग-अलग हो सकते हैं. आसानी से रेफ़रंस के लिए, इनके बारे में नीचे दी गई टेबल में बताया गया है.
ज़रूरी शर्तें
इस गाइड में यह माना गया है कि आपने Unity को पहले ही इंस्टॉल और कॉन्फ़िगर कर लिया है. अगर ऐसा नहीं है, तो इंस्टॉल करने और सेटअप करने के तरीके के बारे में जानने के लिए, AR Foundation के लिए ARCore एक्सटेंशन का इस्तेमाल शुरू करना लेख पढ़ें.
इंस्टैंट प्लेसमेंट (पर्सिस्टेंट रेकास्ट) की सुविधा, AR Foundation पैकेज के साथ पहले से उपलब्ध है. अपना सीन सेट अप करने के लिए, यह तरीका अपनाएं.
AR Foundation 4.x
पहले से तय किए गए गेम ऑब्जेक्ट AR Session Origin और
AR Session जोड़ें.

AR Raycast Manager कॉम्पोनेंट को AR Session Origin गेम ऑब्जेक्ट में जोड़ें.

जब रेकास्ट प्रीफ़ैब शून्य नहीं होता है, तो ARRaycastManager
प्रीफ़ैब को इंस्टैंशिएट करेगा और उसकी पोज़िशन को ARRaycast
की पोज़िशन के साथ अपने-आप सिंक करेगा.
AR Foundation 5.x
पहले से तय किए गए गेम ऑब्जेक्ट XR Origin और
AR Session जोड़ें.

AR Raycast Manager कॉम्पोनेंट को XR Origin गेम ऑब्जेक्ट में जोड़ें.

जब रेकास्ट प्रीफ़ैब शून्य नहीं होता है, तो ARRaycastManager
प्रीफ़ैब को इंस्टैंशिएट करेगा और उसकी पोज़िशन को ARRaycast
की पोज़िशन के साथ अपने-आप सिंक करेगा.
AR Foundation 6.x
पहले से तय किए गए गेम ऑब्जेक्ट XR Origin और
AR Session जोड़ें.

AR Raycast Manager कॉम्पोनेंट को XR Origin गेम ऑब्जेक्ट में जोड़ें.

जब रेकास्ट प्रीफ़ैब शून्य नहीं होता है, तो ARRaycastManager
प्रीफ़ैब को इंस्टैंशिएट करेगा और उसकी पोज़िशन को ARRaycast
की पोज़िशन के साथ अपने-आप सिंक करेगा.
ऑब्जेक्ट प्लेस करना
नए ARCore सेशन में, ARRaycastManager.AddRaycast(Vector2, float)
का इस्तेमाल करके हिट टेस्ट करें.
public ARRaycastManager RaycastManager; // set from the Editor Inspector.
void Update()
{
Touch touch;
if (Input.touchCount < 1 || (touch = Input.GetTouch(0)).phase != TouchPhase.Began)
{
return;
}
if (EventSystem.current.IsPointerOverGameObject(touch.fingerId))
{
return;
}
ARRaycast raycast = RaycastManager.AddRaycast(touch.position, _estimateDistance);
if (raycast != null)
{
// You can instantiate a 3D object here if you haven’t set Raycast Prefab in the scene.
…
}
}
ARRaycast ट्रैकिंग की स्थिति पर नज़र रखना
अगर ARCore के पास 3D पोज़ की सटीक जानकारी है, तो ARRaycast.trackingState
Tracking
हो जाएगा.
अगर ऐसा नहीं होता है, तो यह Limited
से शुरू होगा और ARCore के सटीक 3D पोज़ मिलने के बाद, Tracking
पर ट्रांज़िशन हो जाएगा. ट्रैकिंग की स्थिति Tracking
होने के बाद, वह फिर से Limited
नहीं होगी.
जब तक कुछ अलग से न बताया जाए, तब तक इस पेज की सामग्री को Creative Commons Attribution 4.0 License के तहत और कोड के नमूनों को Apache 2.0 License के तहत लाइसेंस मिला है. ज़्यादा जानकारी के लिए, Google Developers साइट नीतियां देखें. Oracle और/या इससे जुड़ी हुई कंपनियों का, Java एक रजिस्टर किया हुआ ट्रेडमार्क है.
आखिरी बार 2025-07-14 (UTC) को अपडेट किया गया.
[null,null,["आखिरी बार 2025-07-14 (UTC) को अपडेट किया गया."],[[["\u003cp\u003eLearn to use the Instant Placement API or persistent raycasts in your AR apps.\u003c/p\u003e\n"],["\u003cp\u003eUnderstand fundamental AR concepts and ARCore session configuration as prerequisites.\u003c/p\u003e\n"],["\u003cp\u003eSet up your scene with AR Session Origin, AR Session, and AR Raycast Manager components.\u003c/p\u003e\n"],["\u003cp\u003ePlace objects by performing hit tests using \u003ccode\u003eARRaycastManager.AddRaycast\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eMonitor the \u003ccode\u003eARRaycast\u003c/code\u003e tracking state to determine the accuracy of the 3D pose.\u003c/p\u003e\n"]]],[],null,["# Instant Placement developer guide for AR Foundation\n\nLearn how to use the\n[Instant Placement API](/ar/develop/unity-arf/instant-placement/overview), or\n[persistent raycasts](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/manual/raycast-manager.html#persistent-raycasts), in your own apps.\n\nPrerequisites\n-------------\n\nMake sure that you understand [fundamental AR concepts](/ar/develop/fundamentals)\nand how to [configure an ARCore session](/ar/develop/unity-arf/session-config) before proceeding.\n\nConcept names\n-------------\n\nNames of certain concepts and methods may differ between AR Foundation and the\nARCore SDK for Unity. These are listed in the table below for easy reference.\n\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| **AR Foundation** | **ARCore SDK for Unity** |\n| [Persistent raycasts](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/manual/raycast-manager.html#:~:text=Persistent%20raycasts,ARRaycastManager%20component%20from%20script%20code.) | Instant Placement |\n| [ARRaycastManager.AddRaycast(Vector2, float)](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/manual/raycast-manager.html#persistent-raycasts) | [Frame.RaycastInstantPlacement(float, float, float, out TrackableHit)](https://developers.google.com/ar/reference/unity/class/GoogleARCore/Frame#raycastinstantplacement) |\n| [ARRaycast](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARRaycast.html) | [TrackableHit](https://developers.google.com/ar/reference/unity/struct/GoogleARCore/TrackableHit) |\n| (No equivalence) | [InstantPlacementPoint](https://developers.google.com/ar/reference/unity/class/GoogleARCore/InstantPlacementPoint) |\n| [ARRaycast.trackingState](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARTrackable-2.html#UnityEngine_XR_ARFoundation_ARTrackable_2_trackingState) | [InstantPlacementPointTrackingMethod](https://developers.google.com/ar/reference/unity/class/GoogleARCore/InstantPlacementPoint?#trackingmethod) |\n\nPrerequisites\n-------------\n\nThis guide assumes you have already installed and configured Unity. If not, see\nthe [Getting started with ARCore Extensions for AR Foundation](/ar/develop/unity-arf/getting-started-extensions)\nfor installation and setup steps.\n\nConfigure a new session with `ARRaycastManager`\n-----------------------------------------------\n\nInstant Placement (persistent raycasts) is available out of the box with the AR\nFoundation package. Follow these steps to set up your scene. \n\n### AR Foundation 4.x\n\n\u003cbr /\u003e\n\n1. Add the predefined game objects **AR Session Origin** and\n **AR Session**.\n\n2. Add the **AR Raycast Manager** component into the\n **AR Session Origin** game object.\n\nWhen Raycast Prefab is not null, [`ARRaycastManager`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/manual/raycast-manager.html)\nwill instantiate the prefab and automatically sync its pose with the pose of\n[`ARRaycast`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARRaycast.html).\n\n\u003cbr /\u003e\n\n### AR Foundation 5.x\n\n\u003cbr /\u003e\n\n1. Add the predefined game objects **XR Origin** and\n **AR Session**.\n\n2. Add the **AR Raycast Manager** component into the\n **XR Origin** game object.\n\nWhen Raycast Prefab is not null, [`ARRaycastManager`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/manual/raycast-manager.html)\nwill instantiate the prefab and automatically sync its pose with the pose of\n[`ARRaycast`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARRaycast.html).\n\n\u003cbr /\u003e\n\n### AR Foundation 6.x\n\n\u003cbr /\u003e\n\n1. Add the predefined game objects **XR Origin** and\n **AR Session**.\n\n2. Add the **AR Raycast Manager** component into the\n **XR Origin** game object.\n\nWhen Raycast Prefab is not null, [`ARRaycastManager`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/manual/raycast-manager.html)\nwill instantiate the prefab and automatically sync its pose with the pose of\n[`ARRaycast`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARRaycast.html).\n\n\u003cbr /\u003e\n\nPlace an object\n---------------\n\nIn a new ARCore session, perform a hit test using\n[`ARRaycastManager.AddRaycast(Vector2, float)`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARRaycastManager.html#UnityEngine_XR_ARFoundation_ARRaycastManager_AddRaycast_UnityEngine_Vector2_System_Single_). \n\n public ARRaycastManager RaycastManager; // set from the Editor Inspector.\n\n void Update()\n {\n Touch touch;\n if (Input.touchCount \u003c 1 || (touch = Input.GetTouch(0)).phase != TouchPhase.Began)\n {\n return;\n }\n\n if (EventSystem.current.IsPointerOverGameObject(touch.fingerId))\n {\n return;\n }\n\n ARRaycast raycast = RaycastManager.AddRaycast(touch.position, _estimateDistance);\n if (raycast != null)\n {\n // You can instantiate a 3D object here if you haven't set Raycast Prefab in the scene.\n ...\n }\n }\n\nMonitor the ARRaycast tracking state\n------------------------------------\n\nIf ARCore has an accurate 3D pose, the [`ARRaycast.trackingState`](https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.2/api/UnityEngine.XR.ARFoundation.ARTrackable-2.html#UnityEngine_XR_ARFoundation_ARTrackable_2_trackingState) will be [`Tracking`](https://docs.unity3d.com/Packages/com.unity.xr.arsubsystems@4.2/api/UnityEngine.XR.ARSubsystems.TrackingState.html).\nOtherwise, it will start with [`Limited`](https://docs.unity3d.com/Packages/com.unity.xr.arsubsystems@4.2/api/UnityEngine.XR.ARSubsystems.TrackingState.html)\nand transition to [`Tracking`](https://docs.unity3d.com/Packages/com.unity.xr.arsubsystems@4.2/api/UnityEngine.XR.ARSubsystems.TrackingState.html) once ARCore has an accurate 3D pose. Once the tracking state becomes [`Tracking`](https://docs.unity3d.com/Packages/com.unity.xr.arsubsystems@4.2/api/UnityEngine.XR.ARSubsystems.TrackingState.html),\nit will not revert to\n[`Limited`](https://docs.unity3d.com/Packages/com.unity.xr.arsubsystems@4.2/api/UnityEngine.XR.ARSubsystems.TrackingState.html)."]]