How to disable script from another script until specific animation state has been activated.
I am making a 2D game where when you press the play button on the main menu the background plays an animation and when it finishes playing the animation it moves on to the next. I want to disable the player movement script until the background moves from the first animation to the second.
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NoMovement : MonoBehaviour
{
bool Noon;
public GameObject Player_1;
Animator anim;
Animation anima;
static int idleState = Animator.StringToHash("Idle");
PlayerOne P1;
public AnimatorStateInfo currentBaseState { get; private set; }
// Use this for initialization
void Start()
{
anim = GetComponent<Animator>();
P1 = GameObject.Find("Player 1").GetComponent<PlayerOne>();
}
// Update is called once per frame
void Update()
{
if (anima.IsPlaying("BackgroundStill"))
{
P1.enabled = true;
}
if (anima.IsPlaying("Background"))
{
P1.enabled = false;
}
}
void FixedUpdate()
{
currentBaseState = anim.GetCurrentAnimatorStateInfo(0);
if (currentBaseState.fullPathHash == idleState)
{
Debug.Log("Hello");
}
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612114113im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Finding normalized value of divided number 2 Answers
Opening and closing a Gate on Input.GetButtonDown 0 Answers
On Respawn, Player Velocity Set to 0 on all axis? 1 Answer
How can i disable/enable slowly the blur effect using the blur script ? 0 Answers
Why when i color 4 walls of a grid 10x10 it's coloring 10,9,9,8 and not 10,10,10,10 ? 0 Answers