I have seen this question asked a lot but none of their solutions work for me and have not found any that do work or are up to date so I am going to ask here. I have a script that should make it so that when the player walks into the trigger it will play the animation “blob_attack”.
I have tried everything from putting the animation name itself into the code but nothing has worked. I just do not get this animation stuff. If someone could help me sort this out that would be great. (There are no errors in the code just the animation does not play.)
using UnityEngine;
using System.Collections;
public class blob_attack : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "Enemy")
{
GetComponent<Animation>().Play();
}
}
}
