Lizard now has no collider

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);
    }
}

}

Hi gummirk,

Have you already noticed the message in the Lizard’s Rigidbody2D component? It says that the Lizard is not part of the physics simulation anymore. Enable “Simulated”. Did this fix it?

Hi Nina

Damn I overlooked this I already. I did try it but forgot to apply it to prefab
Thanks so much for the help
Regards
Gummi

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms