Created
July 2, 2020 19:35
-
-
Save kurtkaiser/217b68a2fd84381b8b7e693221c01801 to your computer and use it in GitHub Desktop.
Dungeon Crawl RPG - game made for a video tutorial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class WeaponColliderScript : MonoBehaviour | |
{ | |
public GameObject player; | |
private float weaponDamage; | |
private void OnTriggerEnter2D(Collider2D collision) | |
{ | |
weaponDamage = transform.parent.gameObject.GetComponent<WeaponScript>().weaponPower; | |
if (collision.gameObject.CompareTag("Enemy")) | |
{ | |
collision.gameObject.GetComponent<EnemyScript>().TakeDamage(weaponDamage); | |
} | |
if (collision.gameObject.CompareTag("Spawner")) | |
{ | |
collision.gameObject.GetComponent<SpawnerScript>().TakeDamage(weaponDamage); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment