Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question How to set position of an gameobject that is spawned using Image Tracker in AR Foundation

Discussion in 'AR' started by Prahelika07, Aug 11, 2023.

  1. Prahelika07

    Prahelika07

    Joined:
    Feb 3, 2023
    Posts:
    35
    Hello.
    I am developing a scene where a fbx model will be spawned after tracking an image. But the issue is that it is spawned keeping the image and the model center same point which I don't want. I want to set the model according the desirable location respect to the image marker.

    Will it be possible?
     
  2. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    4,540
    Share the code you already have for the image tracking.

    Everything is possible (;
     
  3. Prahelika07

    Prahelika07

    Joined:
    Feb 3, 2023
    Posts:
    35
    I haven't written any code. It is the inbuilt feature script of AR Foundation named as "AR Tracked Image Manager".
     
  4. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,072
  5. Prahelika07

    Prahelika07

    Joined:
    Feb 3, 2023
    Posts:
    35
    I was using Vuforia but with that I have size issues. The size of the model that is shown in AR is way bigger than the model that was made. If you know how to resize the model in vuforia, it will be helpful
     
  6. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,072
    in vuforia the size depends on the marker size or some other scale, already forgot where.
    but should be in their docs.
     
  7. Prahelika07

    Prahelika07

    Joined:
    Feb 3, 2023
    Posts:
    35
    what I read, it was based on camera distance or something. but it didn't worked either.
     
    Last edited: Aug 11, 2023
  8. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,072
  9. Prahelika07

    Prahelika07

    Joined:
    Feb 3, 2023
    Posts:
    35
  10. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,072
    if model is correct scale already, it shouldn't matter.
    (but not sure, i always used fixed size A4 marker and printed marker was A4 same size)
     
  11. Prahelika07

    Prahelika07

    Joined:
    Feb 3, 2023
    Posts:
    35
    I have tried this method but the model is fluctuating and if I try to spawn other object(which is required) it is also fluctuation like crazy.
     
  12. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,072
    yeah AR tracking is still pretty bad in most cases..
    (even on latest ipad Lidars the model doesn't stay on place when moving)
     
  13. Prahelika07

    Prahelika07

    Joined:
    Feb 3, 2023
    Posts:
    35
    It was working well without the model addition but it crashed after changing the image marker size...:(:(
    And I'm using iPad just for this only...
     
  14. Nikabanzai

    Nikabanzai

    Joined:
    Jul 6, 2023
    Posts:
    6
    I am working on a similar project, so if I understood correctly you only use the A4 for the size scale and not attach the object to it?
    What I want to do is to spawn the object relative to an A4 to scale 1:1 real life and then attach to that place but I want it to be movable. The problem using AR Image Tracker is that the prefab gets destroyed when the trigger reference image is not in the scene anymore. How can I do that would you suggest?
     
  15. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,072
    i moved objects with offset tools (using UI),
    which then searched for my trackableobject in scene, if available,
    moved the child transform (not the root prefab transform).
    (so the tracking & object placement comes from Image and extended tracking, but user can offset model manually, and can save/load the offset if needed)

    not sure if thats the best way, but works..
     
    Nikabanzai likes this.
  16. Prahelika07

    Prahelika07

    Joined:
    Feb 3, 2023
    Posts:
    35
    Whenever I have used AR Image Tracker, none of my model got destroyed though it has moved from its position now and then. Maybe there is some code that you have written or selected some settings that destroys the model when you move the screen away from the image.
     
    Nikabanzai likes this.
  17. Nikabanzai

    Nikabanzai

    Joined:
    Jul 6, 2023
    Posts:
    6
    Thanks I rechecked and yes you are right I delete the prefab whe nthe ref iamge is out of screen. And now to modify I will adjust the x,y,z of the prefab acxcordingly getting touch inputs hopefully!
     
  18. Prahelika07

    Prahelika07

    Joined:
    Feb 3, 2023
    Posts:
    35
    Happy, that it helped. :)
     
  19. levoxtrip

    levoxtrip

    Joined:
    May 4, 2020
    Posts:
    48
    Yeah I have problems with my rotation. Everytime i scan an Image the image has a different rotation! Any Tipps for that?
     
  20. levoxtrip

    levoxtrip

    Joined:
    May 4, 2020
    Posts:
    48
    Do you guys recommend using vuforia. I have some projects now i need to work with AR und stable positioning and Rotation of the AR Objects is really important. ARCore and ARFoundation seems to buggy or I don't know how to position them properly. I'm using anchors for my prefab but still get some sliding.
     
  21. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,072
    used vuforial really long time ago.. then the licensing ruined it, but the tracking was ok from what i remember..

    ar foundation, have same issues with models sliding, not usable for any kind of precision requiring work..
    (or at least havent found the settings that would improve it)
     
  22. levoxtrip

    levoxtrip

    Joined:
    May 4, 2020
    Posts:
    48
    Yeah exactly have that sliding problem as well. Can you recommend an alternative or a working framework for AR and Unity. Its gonna be quite some projects :/
     
  23. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,072
    still looking also.. would prefer something that can track point cloud or model based tracker.

    hololens 2 ar demos look pretty impressive, how the tracking is exact.. not sure how they do it and why it wouldnt work on mobiles (like ipad with lidar?)
     
  24. Prahelika07

    Prahelika07

    Joined:
    Feb 3, 2023
    Posts:
    35
    Well, right now I am working with Vuforia with size of object spawn with image target around 100m+ and it is working fine.

    I would have recommended Unity MARS but recently its image marker tracking going little south and scene changing causing issues but you can keep track of that as if the issues get solved, it can go smooth and help you in future.