Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class EnemyDamage : MonoBehaviour
- {
- public GameObject enemyCorpse;
- private void OnCollisionEnter(Collision collision)
- {
- Debug.Log("Collided"); // This is not printing.
- // Check if collision is with player.
- if (collision.collider.gameObject.tag == "Player")
- {
- PlayerHealth playerHealth = collision.collider.gameObject.GetComponent<PlayerHealth>();
- GameObject corpseClone = Instantiate(enemyCorpse, transform.position, Quaternion.identity);
- Destroy(gameObject);
- playerHealth.health -= 1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement