Hello,
I’ll start out by saying I’m really new to C# and Unity. I have a script that is looking for a player collision and inflicting player damage on contact. Currently I have my little monster running about but he’s harmless unfortunately.
When my player collides with the enemy no damage is taken. I added a debug log to the script but I’m not getting anything in console. no errors or debug log. I’m guessing that means my player and enemy are not actually colliding. I have my stopping distance turned down to 0 my enemy and I practically overlap if I stand still. But no collision. I’ve added ridged bodies to both myself and the enemy, we also have capsule colliders set as triggers. I’m out of ideas. Any help would be greatly appreciated!!
using UnityEngine;
using System.Collections;
using UnityStandardAssets.Characters.FirstPerson;
public class EnemyDamage : MonoBehaviour
{
public int damage;
public PlayerInventory playerInventory;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
}
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.tag == "Player")
{
playerInventory.currentHealth = damage;
Debug.Log("hello");
}
}
}