Skip to content

Instantly share code, notes, and snippets.

@didacus
Created November 14, 2021 15:28
Show Gist options
  • Save didacus/196dee2ef0de6af9934dc2e4d9a216f1 to your computer and use it in GitHub Desktop.
Save didacus/196dee2ef0de6af9934dc2e4d9a216f1 to your computer and use it in GitHub Desktop.
Unity - Basic player damage
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DamagePlayer : MonoBehaviour
{
public int damageToGive;
public void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "Player")
{
other.gameObject.GetComponent<PlayerHealthManager>().DamagePlayer(damageToGive);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment