Good morning.
I want that, if the player passes a point, an animation triggers.
I already made a trigger collider, and the debug.log (“paso”) is working good, but the animations doesn’t run.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class AnimatorManager : MonoBehaviour {
public float restartDelay;
Animator anim;
float restartTimer;
public GameObject Player;
public GameObject EndLevel;
/*void Start ()
{
HasDied = false;
}*/
void Update ()
{
if (GameObject.FindGameObjectWithTag ("Player") == null)
{
anim.SetTrigger ("PlayerIsDead");
restartTimer += Time.deltaTime;
if (restartTimer >= restartDelay)
{
SceneManager.LoadScene ("_scene01");
}
}
}
void OnTriggerEnter2D (Collider2D trig)
{
if (EndLevel.gameObject.tag == "Meta" && Player.gameObject.tag == "Player" )
{
Debug.Log ("paso");
anim.SetTrigger ("PlayerWins");
restartTimer += Time.deltaTime;
if (restartTimer >= restartDelay)
{
SceneManager.LoadScene ("_scene01");
}
}
}
void Awake ()
{
anim = GetComponent<Animator> ();
}
}