I need some help with onTriggerEnter, I want to be able to have attack the enemy (with Input.GetMouseButtonDown(0) and also need to have to have a collision with the ShortSword game object, but it is not working! I want my enemy to loose health if he gets touched by the ShortSword and mousebutton is down. Also I am working in 2D. thx for the help
using UnityEngine;
using System.Collections;
public class Enemy : MonoBehaviour {
public float Health = 100;
public GameObject ShortSword;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if(Input.GetMouseButtonDown(0) && OnTriggerEnter(ShortSword))
{
Health=Health - 10;
Debug.Log(Health);
}
}
}