Log in or register to post comments

Restart animation when the marker was lost

May 21, 2012 - 7:28am #1

Hi,
We are using the DefaultTrackableEventHandler as the start for an individual EventHandler.
As soon as a marker is found an animation is started. When the marker is lost the animation disappears and should stop. Animation is triggered from within a javascript file.

 
function Update () {
	  playAnimation(anims);
}

What we are trying to achieve is that as soon as the marker is found again the animation should start from the beginning again. Currently it starts from it’s last position.
So how do we either reset the status of the animation to it’s initial position or how do we reinit the trackable. Any suggestions?

Restart animation when the marker was lost

September 6, 2019 - 1:23pm #10

good afternoon, how are you, could you make the animation start from the beginning when the marker is lost?

 

 

 

Restart animation when the marker was lost

January 31, 2018 - 5:38am #9

Hi,

I am wondering about the arguments you pass in .Play().

  1. is "Take 001" the name of a state or animated object?
  2. I assume that '-1' is a time setting. Is that correct?
  3. What is '0f'?

When I try to use this, it returns an error: "No overload for method 'Play' takes '3' arguments"

Thanks

Restart animation when the marker was lost

July 12, 2016 - 11:20pm #8

Try this it work like charm

 

private void OnTrackingFound()

{   

// I have added this code to restart animation when marker found

            Animator[] animatorComponents = GetComponentsInChildren<Animator>();

            foreach (Animator anim in animatorComponents)
            {
                anim.Play("Take 001", -1, 0f);
                Debug.Log("***anim component: " + anim.name);
            }

            // Enable rendering:
            foreach (Renderer component in rendererComponents)
            {
                if (component.name != "Video" && component.name != "Icon")
                {
                    component.enabled = true;
                }
            }

}

Restart animation when the marker was lost

April 7, 2016 - 5:19am #7

Hi

I really need an answer to this aswell. I am not a coder so any help here would be greatly appreciated. 

I had thought this would be as simple as a check box..

 

Thanks

Declan

Restart animation when the marker was lost

January 11, 2014 - 3:03pm #6

Is that the DefaultTrackableEventHandler script?

Re: Restart animation when the marker was lost

May 22, 2012 - 7:51am #5

We have a solution:

In the TrackableEventHandler script:

private void OnTrackingFound()
    {
        Renderer[] rendererComponents = GetComponentsInChildren<Renderer>();
	
        // Enable rendering:
        foreach (Renderer component in rendererComponents) {
            component.enabled = true;
        }
		
		Animation[] array = mTrackableBehaviour.GetComponentsInChildren<Animation>(	false);
		foreach (Animation r in array)
		{
			r.Rewind();
		}
		
        Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found");
    }


    private void OnTrackingLost()
    {

        Renderer[] rendererComponents = GetComponentsInChildren<Renderer>();
		

		// Disable rendering:
        foreach (Renderer component in rendererComponents) {
            component.enabled = false;
		}

    }

    #endregion // PRIVATE_METHODS
}

Re: Restart animation when the marker was lost

May 22, 2012 - 5:10am #4

hm... seams like we can`t use the "Animation" function in the TrackableEventHandler because Animation is null...

We think the problem is a java/C# communication problem.
The TrackableEventHandler doesn't recognize the Java animation queue...

I think we need to reset the Gameobject...

Any idea how to do this?

Edit: Or should we translate the animation script to C#?

Re: Restart animation when the marker was lost

May 21, 2012 - 5:33pm #3

Have you tried calling animation.Rewind() within the OnTrackingLost() call - e.g. in Default Trackable Event Handler.

Re: Restart animation when the marker was lost

May 21, 2012 - 4:15pm #2

Hi Ihno,

I would suggest copying the DefaultEventTrackableHandler and adding Animation.Play() and Animation.Stop() in the OnTrackingFound and OnTrackingLost() functions.

You'll also need to set the Culling Type to 'Always Animate' in order to allow the animation to be reset after its played. If you need to pause the animation instead of Play()/Stop() you'll want to set the AnimationState.speed parameter to 1.0f and 0.0f to play and pause.

Hope that helps.
C

Log in or register to post comments