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 How to use OnChanged removedImage correctly?

Discussion in 'AR' started by jreutelsterz, Sep 19, 2022.

  1. jreutelsterz

    jreutelsterz

    Joined:
    Dec 10, 2021
    Posts:
    31
    In one of my projects I am usinga cube filled with pictures. Each of the pictures has his own model which is
    instantiated based on the position of the picutre. I just want to track the picture on top of the cube. Therefore I use the up vector. Now I tried it and have the problem on my iPad that the generated Modells aren't deleted correctly. There is also a Dictionary spawnedCharacter in which I store the one tracked image and fitting model. There should be just place for the one pair to ensure that there is just the one.

    I am now struggeling with the removedImage Part and don't know how to go on or do it properly.

    PS: I checkt it further and noticed that Im not entering the removedImage section at all. Used a Debug Line to see if I get inside

    Thanks for your Help!
     
    Last edited: Oct 2, 2022
  2. davidmo_unity

    davidmo_unity

    Unity Technologies

    Joined:
    Jun 18, 2019
    Posts:
    99
    Generally, you should be parenting your spawned content to the generate ARTrackedImage when tracking begins to implicitly capture pose updates and when remove gets called the parent ARTrackedImage will get destroyed which will also destroy your contentl.
     
  3. jreutelsterz

    jreutelsterz

    Joined:
    Dec 10, 2021
    Posts:
    31
    Hi, so I tried to figure it out and just found the way via transform.SetParent. Is there any other SetParent Option or is it that one?
     
  4. davidmo_unity

    davidmo_unity

    Unity Technologies

    Joined:
    Jun 18, 2019
    Posts:
    99
    That is the one
     
  5. jreutelsterz

    jreutelsterz

    Joined:
    Dec 10, 2021
    Posts:
    31
    Line 101 and 129 contain the setParent parameter
     
    Last edited: Oct 2, 2022
  6. jreutelsterz

    jreutelsterz

    Joined:
    Dec 10, 2021
    Posts:
    31
    I tried to use it in the instantiation, update and both but sadly the Object is mostly set to my ARSessionOrigin Coordinate and not on the Image. Also I have a very hard jitter and the model moves to fast on its position.
     
  7. andyb-unity

    andyb-unity

    Unity Technologies

    Joined:
    Feb 10, 2022
    Posts:
    1,018
  8. jreutelsterz

    jreutelsterz

    Joined:
    Dec 10, 2021
    Posts:
    31
    andyb-unity likes this.