Skip to content

Instantly share code, notes, and snippets.

@kurtkaiser
Created July 2, 2020 19:35
Show Gist options
  • Save kurtkaiser/217b68a2fd84381b8b7e693221c01801 to your computer and use it in GitHub Desktop.
Save kurtkaiser/217b68a2fd84381b8b7e693221c01801 to your computer and use it in GitHub Desktop.
Dungeon Crawl RPG - game made for a video tutorial
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