Hi,
i know i know ... a question you may have read alot of times. Why isnt my model moving on target found? ☺
I tried nearly every constelation i found suggested in this forum but none of thme worked.
The Animation is running when i loop it, but because I want to sync it with audio I on target found it must not be looped.
(FBX Object with baked Animations)
My Workflow :
I drag my model into the scene into an objectTarget Object.
The Object itself gets an AnimatorObject (instance? however)
but it has no controller and i cant see the clips ( I can see the clips in the Assets folder in the subtree of the model )
So i drag the clip to the Model and it get a controller and in the Animator view the clip apears.
I added a script to the Object Tracker
using UnityEngine; using System.Collections; using Vuforia; public class NewBehaviourScript1 : MonoBehaviour, ITrackableEventHandler { private TrackableBehaviour mTrackableBehaviour; Renderer[] rendererComponents; Animation[] animationComponents; void Start() { rendererComponents = GetComponentsInChildren<Renderer>(); animationComponents = GetComponentsInChildren<Animation>(); mTrackableBehaviour = GetComponent<TrackableBehaviour>(); if (mTrackableBehaviour) { mTrackableBehaviour.RegisterTrackableEventHandler(this); } } public void OnTrackableStateChanged( TrackableBehaviour.Status previousStatus, TrackableBehaviour.Status newStatus) { if (newStatus == TrackableBehaviour.Status.DETECTED || newStatus == TrackableBehaviour.Status.TRACKED || newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED) { // Play audio when target is found GetComponent<Animation>().Play(); GetComponent<AudioSource>().Play(); } else { GetComponent<Animation>().Stop(); GetComponent<AudioSource>().Stop(); } } }
But the model is not moving on Target found.
I tried adding an animation component to the Model and selected the clip. not working..
I tried adding an animation component to the ObjectTracker and selected the clip. not working..
I tried using the Animator (but i a mnot sure how to use it in the script to "trigger" the animation clip.
I read a lot of forum entries and even whatched the tutorial videos about the animator and the scripting and
tried many different ways but none of them brought me to the final goal to just play the animation when the
target is found (like the audio does) and stop it whe the target ist lost (like the audio does)
It play the animation when i hit the play button in unity.
I am on Android 5.1 (Jiayu S3)
Pleas help. =)
Thankx!
Animation is not playing on target found
Hi,
Try as a test adding a Button so when you press it, it plays the animation and sound. See if that works.
Try also having just one database with one target and containing in that target the code you posted.
Animation is not playing on target found
HI Thanks for the Answer..
I figured it out by myself.
I had to access the animator of my johnny bravo object .. The GameObject is the Object / Image Target but the Animator is on the Johnny Bravor object (only then i can see the animation)
Animation is not playing on target found
how did you do it can you show me your code? thanks
Thank you, I appreciate you
Thank you, I appreciate you for sharing the solution (not a coder here). So it's helped heaps, cheers!