Lyim

Untitled

Apr 20th, 2021
976
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class EnemyDamage : MonoBehaviour
  6. {
  7.  
  8.     public GameObject enemyCorpse;
  9.  
  10.     private void OnCollisionEnter(Collision collision)
  11.     {
  12.         Debug.Log("Collided"); // This is not printing.
  13.         // Check if collision is with player.
  14.         if (collision.collider.gameObject.tag == "Player")
  15.         {
  16.             PlayerHealth playerHealth = collision.collider.gameObject.GetComponent<PlayerHealth>();
  17.             GameObject corpseClone = Instantiate(enemyCorpse, transform.position, Quaternion.identity);
  18.             Destroy(gameObject);
  19.             playerHealth.health -= 1;
  20.         }
  21.     }
  22.  
  23. }
  24.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×