Answer the question
In order to leave comments, you need to log in
Why does it swear at Play() in GetComponent() - Unity?
I'm trying to run an animation and Animation. The second day I'm scratching my head why so? (comment in code)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class DetectClicks : MonoBehaviour
{
public GameObject buttons, m_cube;
public Text playText, gameName;
private bool clicked;
private void OnMouseDown()
{
if (!clicked)
{
clicked = true; //если еще не стартовали, то стартуем
playText.gameObject.SetActive(false);//деактивируем
gameName.text = "0"; //обнуляем название игры
buttons.GetComponent<ScrollObjects>().speed = -10;
buttons.GetComponent<ScrollObjects>().checkPos = -180f;
m_cube.GetComponent<Animation>().Play("GoToStart"); //тут ругается на Play
}
}
}
Answer the question
In order to leave comments, you need to log in
Updated, rewritten, deleted, nothing has changed ...
I solved the issue through Animator.
m_cube.GetComponent<Animator>().Play("GoToStart");
The Animator itself had to be tweaked a bit...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question