Search Unity

Question Misplaced objects after loading Scene with image detection

Discussion in 'AR' started by levoxtrip, Sep 25, 2022.

  1. levoxtrip

    levoxtrip

    Joined:
    May 4, 2020
    Posts:
    48
    Hallo everyone,

    i'm working on a project right now where i'm initialising new scenes through image detection. My problem is after the image get's tracked successfully and loading the new scenes the objects in the new scene get initialised on wrong positions / misplaced.

    The red shape is suppose to be Around me or more I am standing in it ->
    Instantiate(gOb, gOb.transform);

    gOb.transform from the prefab is 0,0,0

    Has anyone an idea why that happens?

    Here is a video
    https://www.reddit.com/r/Unity3D/comments/xnf750/unity_ar_objects_get_misplaced_when_new_scene/

    Thanks in advance
    Cheers Leon
     
  2. andyb-unity

    andyb-unity

    Unity Technologies

    Joined:
    Feb 10, 2022
    Posts:
    1,062
    Your arguments to instantiate are self-referential here. You are instantiating the prefab at the Prefab's position, which will look at the prefab in your Assets directory and use the position of its Transform.

    If you want to instantiate the prefab at a specific position in the scene, use a position in the scene as your argument to Instantiate. See our sample scene for a reference implementation: https://github.com/Unity-Technologies/arfoundation-samples#imagetrackingwithmultipleprefabs