I am using an animated sprite to collide and delete an enemy sprite. The enemy sprite disappears when it hits my floor (sprite) also. (All have rigidbody2D). How do I get the enemy sprite to ignore the floor and everything else except the animated sprite?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Collision : MonoBehaviour
{
void Start()
{
}
void Update()
{
}
void OnCollisionEnter2D()
{
if (gameObject.tag.Equals("Enemy"))
{
Destroy(gameObject);
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.