예제 #1
0
    void OnCollisionStay2D(Collision2D col)
    {
        var            data          = col.gameObject.GetComponent <CollisionData>();
        COLLISION_TYPE collisionType = data ? data.type : COLLISION_TYPE.UNKNOWN;

        lastCollisionData = data;
        lastCollisionDir  = movement.LastDirection;
        movement.Stop();
        UpdateAnimation();
        transform.position = movement.FixPosition(transform.position);

        // detect collision type
        Debug.Log("COLLISION STAY on: " + col.gameObject.transform.position.ToString() + ", button: " + lastCollisionDir + ", type: " + collisionType.ToString());
    }
예제 #2
0
    void OnCollisionEnter2D(Collision2D col)
    {
        CollisionData  data          = col.gameObject.GetComponent <CollisionData>();
        COLLISION_TYPE collisionType = data ? data.type : COLLISION_TYPE.UNKNOWN;

        lastCollisionData = data;
        lastCollisionDir  = movement.LastDirection;
        StopMoving();

        // detect collision type
        Debug.Log("COLLISION ENTER on: " + col.gameObject.transform.position.ToString() + ", button: " + lastCollisionDir + ", type: " + collisionType.ToString());
        // TODO: play collision sound

        if (data is CollisionData)
        {
            data.PlaySound();
        }
    }