horiaci_drak/Assets/scripts/enemykiller.cs
2022-04-27 19:12:55 +02:00

43 lines
1.1 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class enemykiller : MonoBehaviour
{
// Start is called before the first frame update
public ParticleSystem part;
public List<ParticleCollisionEvent> collisionEvents;
void Start()
{
part = GetComponent<ParticleSystem>();
collisionEvents = new List<ParticleCollisionEvent>();
}
// Update is called once per frame
void Update()
{
}
//on particle coolision
void OnParticleCollision(GameObject otherx)
{
int numCollisionEvents = part.GetCollisionEvents(otherx, collisionEvents);
int i = 0;
while (i < numCollisionEvents)
{
GameObject other = collisionEvents[i].colliderComponent.gameObject;
if (other.tag == "enemy")
{
Destroy(other);
Debug.Log("enemy killed");
}
if (other.tag == "king")
{
Destroy(other);
Debug.Log("killed king");
}
i++;
}
}
}