How do I make an animation occur when a sprite it touching another?

Updated on December 17, 2017 in [A] 2D
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
0 on December 17, 2017

I’ve been stuck for a couple of hours and couldn’t find anything so far so is there a way I can make it so when one of my sprites touch another it plays an animation?

Code so far.

using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour
{
Animator anim;
void OnCollisionEnter2D(Collision2D coll)
{
if (coll.collider == true)
{
animation.Play("EggsDee");
}
}
}
  • Liked by
Reply