public void checkCollisionable(GameObject g)
    {
        CustomCollisionProperties otherProp = g.GetComponent <CustomCollisionProperties>();
        Collider2D oc = g.GetComponent <Collider2D>();

        if (oc == null || otherProp == null)
        {
            return;
        }


        if (otherProp != null)
        {
            //Debug.Log("Checking: " + oc.gameObject + " from script: " + otherProp);
            if (physicCollisions.Contains(otherProp.getObjectType()) || otherProp.physicCollisions.Contains(getObjectType()))
            {
                //OnCollision();
            }
            else
            {
                Physics2D.IgnoreCollision(selfCollider, oc);
            }
        }
        else
        {
            //Physics2D.IgnoreCollision(selfCollider, oc);
        }
    }
Beispiel #2
0
    // If the magic enters in contact with another collider
    private void OnTriggerEnter2D(Collider2D collider)
    {
        // Check if the other object has a "CustomCollisionProperties" script.
        CustomCollisionProperties otherProp = collider.gameObject.GetComponent <CustomCollisionProperties>();

        Debug.Log("La magia colisiona con: " + otherProp.gameObject);
        if (otherProp != null)
        {
            if (collidableTypes.Contains(otherProp.getObjectType()) && !consumed)
            {
                consumed = true;
                OnCollision();
                // Tell the other gameobject to apply any magic effect against them.
                applyMagicEffect(collider);
            }
            else
            {
                Physics2D.IgnoreCollision(selfCollider, collider);
            }
        }
        else
        {
            Physics2D.IgnoreCollision(selfCollider, collider);
        }
    }