IMPORTANT ADDITION: 👉🏽 For the seconds part, letting the user place the objects, you can also use the ARWorldPositioningCameraHelper to make your life easier. It will let you automatically access the current GPS coordinates of your camera. The ARWorldPositioningCameraHelper is being automatically attached in play mode to your camera under XR origin when using Lightship WPS . You can simply create a reference to it and then use the latitude and longitudes values from the ARWorldPositioningCameraHelper to spawn the objects. The whole script could look like this: using System.Collections; using System.Collections.Generic; using UnityEngine; using Niantic.Experimental.Lightship.AR.WorldPositioning; using Niantic.Experimental.Lightship.AR.XRSubsystems; using UnityEngine.UI; public class AddWPSObjects : MonoBehaviour { [SerializeField] ARWorldPositioningObjectHelper positioningHelper; [SerializeField] private ARWorldPositioningManager _positioningManager; [SerializeField] private Button button; //Add some random materials [SerializeField] private List cubeMaterials; //Reference the helper private ARWorldPositioningCameraHelper _arWorldPositioningCameraHelper; void Start() { //Find the helper in the scene _arWorldPositioningCameraHelper = FindObjectOfType(); button.onClick.AddListener(SpawnObjectAtPosition); _positioningManager.OnStatusChanged += OnStatusChanged; } private void OnStatusChanged(WorldPositioningStatus obj) { Debug.Log("WPS Status Changed " + obj); } void SpawnObjectAtPosition() { //Use it to determine the GPS position double latitude =_arWorldPositioningCameraHelper.Latitude; double longitude = _arWorldPositioningCameraHelper.Longitude; double altitude = 0.0; GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube); cube.GetComponent().material = cubeMaterials[Random.Range(0, cubeMaterials.Count-1)]; cube.transform.localScale *= .75f; positioningHelper.AddOrUpdateObject(cube, latitude, longitude, altitude, Quaternion.identity); Debug.Log("Placing Object at: latitude:" + latitude + " longitude: " + longitude); }
do you think its possible to do this with 3D models of an object of a real world object but have the camera view correct the placement of the object? the gps location is not accurate enough, so i get misaligned objects with its real world counterpart a lot. i was thinking of using openCV edge and corner detection to identify real objects and line it up with the 3d object.let me know what you think,
Assets\PreplaceWorldObjects.cs(36,34): error CS0246: The type or namespace name 'ARWorldPositioningStatus' could not be found (are you missing a using directive or an assembly reference?) I have this error when i try implementing the first script. WHat could be the cause
So i tried this and added the zlog as nothing was appearing, I've checked all the permissions etc, but im getting the error no tracking and no gnss. Any ideas?
hmm, so if you made sure that you have a good 4G / 5G on your phone it should usually work. Is there any way you can try this on another phone and see if you got the same error?
Thanks for the tutorial! I tried this, but only the second script works properly. I want to pre-place some objects though. I have no errors, but the objects still don't appear on the device. However, when I playtest in Unity, the debug.log statements seem to work well (Placing object at longitude X and latitude Y appear). A bit late, but any suggestions?
Hi mate :) So if I get you right, pre-placing objects does not work for you, because the 3D Objects do not appear at their corresponding positions on device? Did you make sure to set in the Camera settings 14:08 the clipping plane option to 500, or even better something like 10.000 ?
@@AliveStudios_ Hi, thanks for taking the time to reply! I had already set the clipping planes to 10000. My problem is that I am not sure if the loop that spawns the object actually works, because on the android device, the only log that appears is the: Status changed to available. When I run the game on Unity however, the game window shows the following logs: -Status changed to initializing. -[Warning] Package “Lightship World Positioning System (WPS) Plugin" has no loader metadata. Skipping loader initialization. (I saw on the site for ARDK 3.6 Release notes that this error is benign and can be ignored, so I am not sure if that’s the issue). However, in the editor window in Unity, the following debug statements appear: -Added object at latitude X and longitude Y. -Status changed to initializing. -Plugin Lightship World Positioning System (WPS) Plugin" has no loader metadata. Skipping loader initialization.
@@user-xn7yt3oy7z So that means the Debug statement with the added object at latitude X etc. does not appear on your android device.. Is there by any chance another device (e.g. from a friend) that you could test this on? You can try to create a clean build under build setttings -> on the little arrow next to build -> clean build. Maybe this will help. Our first goal should be to get the log statement working on device. Did you also try to set the object at your immediate location, so that you could see them if they were there? Then also make sure that the occlusion manager which we added at 14:10 is turned of / disabled.
Hey :) So this Tutorial can be used to create a standalone game for the play store or App Store, which you could probably advertise on your TikTok account . While it is also possible to create games in effect house , as far as I am concerned, it is not possible to create AR games.
Hey mate :) It is not necessary to set it to iPhone, you can also set it to any android phone you like :). Most likely you do not see iPhone as your build target is set to Android
@@AliveStudios_ yea I select android in the build settings but I didnt saw any option for me to choose any android phone. its a SDK right? but I saw nothing. I saw run device, default device.
@@AliveStudios_ at 3:53 I saw you have a lots of selection but for me I have non of android and iphone at all, I search google but google didnt have the answer..
IMPORTANT ADDITION:
👉🏽 For the seconds part, letting the user place the objects, you can also use the ARWorldPositioningCameraHelper to make your life easier. It will let you automatically access the current GPS coordinates of your camera.
The ARWorldPositioningCameraHelper is being automatically attached in play mode to your camera under XR origin when using Lightship WPS . You can simply create a reference to it and then use the latitude and longitudes values from the ARWorldPositioningCameraHelper to spawn the objects.
The whole script could look like this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Niantic.Experimental.Lightship.AR.WorldPositioning;
using Niantic.Experimental.Lightship.AR.XRSubsystems;
using UnityEngine.UI;
public class AddWPSObjects : MonoBehaviour
{
[SerializeField] ARWorldPositioningObjectHelper positioningHelper;
[SerializeField] private ARWorldPositioningManager _positioningManager;
[SerializeField] private Button button;
//Add some random materials
[SerializeField] private List cubeMaterials;
//Reference the helper
private ARWorldPositioningCameraHelper _arWorldPositioningCameraHelper;
void Start()
{
//Find the helper in the scene
_arWorldPositioningCameraHelper = FindObjectOfType();
button.onClick.AddListener(SpawnObjectAtPosition);
_positioningManager.OnStatusChanged += OnStatusChanged;
}
private void OnStatusChanged(WorldPositioningStatus obj)
{
Debug.Log("WPS Status Changed " + obj);
}
void SpawnObjectAtPosition()
{
//Use it to determine the GPS position
double latitude =_arWorldPositioningCameraHelper.Latitude;
double longitude = _arWorldPositioningCameraHelper.Longitude;
double altitude = 0.0;
GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
cube.GetComponent().material = cubeMaterials[Random.Range(0, cubeMaterials.Count-1)];
cube.transform.localScale *= .75f;
positioningHelper.AddOrUpdateObject(cube, latitude, longitude, altitude, Quaternion.identity);
Debug.Log("Placing Object at: latitude:" + latitude + " longitude: " + longitude);
}
}
tq bro
do you think its possible to do this with 3D models of an object of a real world object but have the camera view correct the placement of the object? the gps location is not accurate enough, so i get misaligned objects with its real world counterpart a lot. i was thinking of using openCV edge and corner detection to identify real objects and line it up with the 3d object.let me know what you think,
Assets\PreplaceWorldObjects.cs(36,34): error CS0246: The type or namespace name 'ARWorldPositioningStatus' could not be found (are you missing a using directive or an assembly reference?)
I have this error when i try implementing the first script. WHat could be the cause
Did you make sure that the WPS package (04:00) was successfully installed?
So i tried this and added the zlog as nothing was appearing, I've checked all the permissions etc, but im getting the error no tracking and no gnss. Any ideas?
hmm, so if you made sure that you have a good 4G / 5G on your phone it should usually work. Is there any way you can try this on another phone and see if you got the same error?
Thanks for the tutorial! I tried this, but only the second script works properly. I want to pre-place some objects though. I have no errors, but the objects still don't appear on the device. However, when I playtest in Unity, the debug.log statements seem to work well (Placing object at longitude X and latitude Y appear). A bit late, but any suggestions?
Hi mate :) So if I get you right, pre-placing objects does not work for you, because the 3D Objects do not appear at their corresponding positions on device? Did you make sure to set in the Camera settings 14:08 the clipping plane option to 500, or even better something like 10.000 ?
@@AliveStudios_ Hi, thanks for taking the time to reply!
I had already set the clipping planes to 10000.
My problem is that I am not sure if the loop that spawns the object actually works, because on the android device, the only log that appears is the: Status changed to available.
When I run the game on Unity however, the game window shows the following logs:
-Status changed to initializing.
-[Warning] Package “Lightship World Positioning System (WPS) Plugin" has no loader metadata. Skipping loader initialization. (I saw on the site for ARDK 3.6 Release notes that this error is benign and can be ignored, so I am not sure if that’s the issue).
However, in the editor window in Unity, the following debug statements appear:
-Added object at latitude X and longitude Y.
-Status changed to initializing.
-Plugin Lightship World Positioning System (WPS) Plugin" has no loader metadata. Skipping loader initialization.
@@user-xn7yt3oy7z So that means the Debug statement with the added object at latitude X etc. does not appear on your android device.. Is there by any chance another device (e.g. from a friend) that you could test this on?
You can try to create a clean build under build setttings -> on the little arrow next to build -> clean build. Maybe this will help.
Our first goal should be to get the log statement working on device. Did you also try to set the object at your immediate location, so that you could see them if they were there? Then also make sure that the occlusion manager which we added at 14:10 is turned of / disabled.
is it possible to create a game using your tutorial in tiktok effect house?
Hey :) So this Tutorial can be used to create a standalone game for the play store or App Store, which you could probably advertise on your TikTok account . While it is also possible to create games in effect house , as far as I am concerned, it is not possible to create AR games.
@@AliveStudios_ thanks
Hi sir sorry for bothering may I know how to set the aspect ratio into iphone? because I search google I just cant search it....
Hey mate :) It is not necessary to set it to iPhone, you can also set it to any android phone you like :). Most likely you do not see iPhone as your build target is set to Android
@@AliveStudios_ but I have non 😓.. I install unity and I have non of it😓
@@justapasserby445 When you click on file (top right) build settings , do you see android or iOS being selected?
@@AliveStudios_ yea I select android in the build settings but I didnt saw any option for me to choose any android phone. its a SDK right? but I saw nothing. I saw run device, default device.
@@AliveStudios_ at 3:53 I saw you have a lots of selection but for me I have non of android and iphone at all, I search google but google didnt have the answer..