Skip to main content
added 394 characters in body
Source Link
JeanLuc
  • 265
  • 1
  • 7

forFor Physics2D the method needs to be called OnCollisionEnter2D and both gameobject needs to have a Collider like BoxCollider2D or CircleCollider2D

public class EnemyMovement : MonoBehaviour 
{
    void OnCollisionEnter2D (Collision2D col)
    {
        if(col.gameObject.name == "player_character")
        {
            Destroy(col.gameObject);
        }
    }
}

For Layer Ordering you are already found the correct property Order In Layer. The red object needs to have a higher number i.e. 1 then the yellow object.

for Physics2D the method needs to be called OnCollisionEnter2D

public class EnemyMovement : MonoBehaviour 
{
    void OnCollisionEnter2D (Collision2D col)
    {
        if(col.gameObject.name == "player_character")
        {
            Destroy(col.gameObject);
        }
    }
}

For Physics2D the method needs to be called OnCollisionEnter2D and both gameobject needs to have a Collider like BoxCollider2D or CircleCollider2D

public class EnemyMovement : MonoBehaviour 
{
    void OnCollisionEnter2D (Collision2D col)
    {
        if(col.gameObject.name == "player_character")
        {
            Destroy(col.gameObject);
        }
    }
}

For Layer Ordering you are already found the correct property Order In Layer. The red object needs to have a higher number i.e. 1 then the yellow object.

Source Link
JeanLuc
  • 265
  • 1
  • 7

for Physics2D the method needs to be called OnCollisionEnter2D

public class EnemyMovement : MonoBehaviour 
{
    void OnCollisionEnter2D (Collision2D col)
    {
        if(col.gameObject.name == "player_character")
        {
            Destroy(col.gameObject);
        }
    }
}