I have spent a few hours trying to get OnCollisionEnter or OnTriggerEnter to fire on a sprite's script without success. The project composition is extremely basic. Just a tilemap and two sprites. The tilemap has a collider via the sprite collection settings, but no rigidbody. The two sprites have colliders, also via the sprite collection settings, and both have rigidbodies. I have increased the collider depth to 10 on all colliders and set their z-axes to 0.
My script looks like this:
public class PlayerScript : MonoBehaviour {
// Use this for initialization
void Start () {
Debug.Log("started");
}
// Update is called once per frame
void Update () {
transform.Translate(-10f * Time.deltaTime, 0, 0);
}
void OnCollisionEnter(Collision collision)
{
Debug.Log("collision entered");
GameObject.Destroy(this);
}
void OnTriggerEnter (Collider other) {
Debug.Log("trigger entered");
GameObject.Destroy(this);
}
}
Do any problems jump out at anyone? I appreciate any help and advice you can offer in advance.