Hi I’m new to using Unity and tried doing collision the original code below is what I tired
So then I tried to just put the col.isTrigger by itself in the if statement it doesn’t show anything in the console log
Help would be greatly appreciated.
public class jabTrigger : MonoBehaviour {
public int jabDamage = 10;
void onTriggerEnter2D(Collider2D col)
{
if (col.isTrigger != true && col.CompareTag("Enemy"))
{
col.SendMessageUpwards("underAttack", jabDamage);
Debug.Log("collision");
}
}
Enemy script
void Update () {
if (currHealth <= 0)
{
Destroy(gameObject);
}
}
public void underAttack(int damage)
{
currHealth -= damage;
Debug.Log(currHealth);
}
}