示例#1
0
    void OnCollisionEnter2D(Collision2D col)
    {
        // Objects with specific collision routines are (e.g. finishes) called here.
        // These each have a script component deriving from the Collidable class,
        // and override PlayerHit() to make this work.
        Collidable collidable = col.gameObject.GetComponent <Collidable>();

        if (collidable != null)
        {
            collidable.PlayerHit(this);
            return; // Stop processing here.
        }
        canJump = true;
    }