Search Unity

Image anchor object animation

Discussion in 'AR' started by dannyp159, Nov 6, 2018.

  1. dannyp159

    dannyp159

    Joined:
    Oct 4, 2018
    Posts:
    2
    Hi there!

    So I've got a scene that has an object that is created via the image anchor method which works fantastically well.

    What I'm trying to do is then have two buttons activate two animations. In this example I have two cubes that are nested in a prefab, I want the first animation to move them apart, and then the second animation brings them back together. Sounds simple enough!

    I'm running into a problem where the animations won't run when the object is 'spawned'. I'm targeting the same prefab in the buttons as is on the 'Generate Image Anchor Script' from my project.

    I've got an animator on the prefab, which then has the two animations to move the cubes.

    Any help with this would be bloody awesome,

    Cheers,
    Danny
     
  2. Voronoi

    Voronoi

    Joined:
    Jul 2, 2012
    Posts:
    590
    My guess is the spawned object's Animator is not being referenced. Try 'GetComponent' on the spawned object to make sure you are referencing the newly created Animator.