Hi i’m trying to make a damage script where when an arrow hits the target that bodypart will take damage.
However i can’t seem to get this to work and i don’t know why.
Hit script
private void OnTriggerEnter(Collider other)
{
Embed();
if (other.CompareTag("Animal"))
{
transform.parent = other.transform;
Debug.Log(other.name);
Health hitHealth = other.GetComponent<Health>();
if (hitHealth != null)
{
hitHealth.TakeDamage(arrowDamage);
}
}
Debug.Log(other.name);
}
TakeDamage Script
public float partHealth;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public void TakeDamage (float amount)
{
partHealth -= amount;
Debug.Log("I " + transform.name + " took " + amount + " damage, and have " + partHealth + " hp left");
if (partHealth <= 0)
{
Debug.Log(transform.name + " part died");
}
}
}
There doesn’t seem to be anything wrong with the collisions since when i hit an object it returns the name but i can’t affect the script in any way