- Home /
The question is answered, found a solution :)
Play an animation by clicking on a Button from the UI for AR
Hello everyone
I am trying to develop an AR app with the Wikitude SDK, but I'm relatively new to coding and Unity in general.
The object that I'm trying to animate is a prefab asset and it contains the script and the controller. It should perform six animations with a click
The Button that I'm using for triggering the Animation ("ButtonAnim") has the object (prefab) and play.Animation() for its On Click () function.
My plan for playing the animation is to set up a Bool ("Move") in the animator.
This is the script that I'm using for the movement
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GetriebeAnim : MonoBehaviour
{
public void PlayAnimation()
{
GetComponent<Animator>().SetBool("Move", true);
}
}
I have also tried to add the controller and the script the the controller game object and then add the controller to the button's on click function but it didn't work either.
Do you know what could be wrong?
Thanks in advance
but when are you playing the animations? in your animator all your animations go to the iddle animation, but it never goes from the iddle to the other animations, or is any code missing?
Thank you for your answer
The animation should only play after clicking on a button on the UI.
You're right with the directions. I've changed them.
I tried to play and I got a warning:
The animator component has an Animator Controller field, make sure its not empty
Follow this Question
Related Questions
Animate an Object by letting it play out in when I press play? 0 Answers
Animator Override Controller Layer Issue 1 Answer
Character starts halfway into ground out of play mode. 0 Answers
How to have one animator controller make multiple objects move? 0 Answers
Change Idle/Walk player animation permanently on trigger colliders 1 Answer