Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Instantiating multiple objects when looking at different images (ARFoundation)

Discussion in 'AR' started by jetlius, Apr 29, 2022.

Thread Status:
Not open for further replies.
  1. jetlius

    jetlius

    Joined:
    Feb 6, 2018
    Posts:
    11
    I'm trying to create an app that spawns (instantiates) multiple different objects in AR, depending on the image that is being detected during runtime.

    I was able to develop all the detection and spawning of the objects for each different image, and the 3D objects even follow the position of those images.

    However, I have been looking for a way to solve an issue with the rotation of those objects. Whenever I instantiate a new object, its rotation doesn't change, i.e. the rotation of the new spawned object is always the same as the first one that was detected during runtime, even if I change scenes during runtime.

    I have tried multiple ways to save the rotation of my trackedImage, and force that rotation onto the gameObject, but it just isn't working, and I don't understand why.

    I tried changing its rotation in the same place where I'm tracking the position (inside UpdateImage), I have tried inside the foreach loops, I have tried changing the rotation only when I'm instantiating, etc, and it just doesn't work.

    This is my ImageTracking script:
     

    Attached Files:

  2. ankur-unity

    ankur-unity

    Unity Technologies

    Joined:
    Aug 12, 2021
    Posts:
    34
Thread Status:
Not open for further replies.