コード例 #1
0
ファイル: HFScript.cs プロジェクト: NicholasCerda/Platformer2
    void OnCollisionEnter(Collision collision)
    {
        if (gameObject.name == "Head" && origidbody.velocity.y > 0)
        {
            if (collision.gameObject.name == "Brick(Clone)")
            {
                Destroy(collision.gameObject);
                guiSc.addScore(100);
            }
            if (collision.gameObject.name == "Question(Clone)")
            {
                GameObject Question = collision.gameObject;
                guiSc.onAddCoin(Question);
            }

            //origidbody.velocity *= 0.0f;
            origidbody.velocity = new Vector3(0, -1, 0);
        }
        else if (gameObject.name == "Feet" /* || gameObject.name == "EthanRightFoot" || gameObject.name == "EthanLeftFoot"*/)
        {
            if (collision.gameObject.name == "Question(Clone)" || collision.gameObject.name == "Brick(Clone)" || collision.gameObject.name == "Rock(Clone)" || collision.gameObject.name == "Stone(Clone)")
            {
                amSc.airborne = false;
                amSc.jump     = false;
                Debug.Log("NotAirborne");
            }
            if (collision.gameObject.name == "GoalPole" && !gameOver)
            {
                gameOver = true;
                guiSc.setWin();
            }
        }
        Debug.Log(gameObject.name + " " + collision.gameObject.name);
    }
コード例 #2
0
 void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.name == "Brick(Clone)" || collision.gameObject.name == "Question(Clone)" || collision.gameObject.name == "Stone(Clone)" || collision.gameObject.name == "Rock(Clone)")
     {
         airborne = false;
     }
     if (collision.gameObject.name == "Brick(Clone)" && movey > 0)
     {
         Destroy(collision.gameObject);
         guiSc.addScore(100);
     }
     if (collision.gameObject.name == "Question(Clone)" && movey > 0)
     {
         GameObject Question = collision.gameObject;
         guiSc.onAddCoin(Question);
     }
 }