Hi I have a problem after I done all for some reason now Projectiles just pass over the lizard and the lizard walks through the defenders. I tried everything even to the the box collider 2d out end set it again. Nothing seams to work. Even when I took out the lizard script the projectiles just went through all. Does anyone have clue why this is happening?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Attacker : MonoBehaviour {
[Range (0f,5f)]
float currentSpeed = 1f;
GameObject currentTarget;
void Update () {
transform.Translate(Vector2.left * currentSpeed * Time.deltaTime);
}
public void SetMovementSpeed(float speed)
{
currentSpeed = speed;
}
public void Attack(GameObject target)
{
GetComponent<Animator>().SetBool("isAttacking", true);
currentTarget = target;
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Lizard : MonoBehaviour {
// Use this for initialization
private void OnTriggerEnter2D(Collider2D otherCollider)
{
GameObject otherObject = otherCollider.gameObject;
if (otherObject.GetComponent<Defender>())
{
GetComponent<Attacker>().Attack(otherObject);
}
}
}