コード例 #1
0
 void OnTriggerEnter2D(Collider2D collider)
 {
     if (collider.tag == "Player")
     {
         ScoreKeeper scoreKeeper = GameObject.FindObjectOfType <ScoreKeeper> ();
         scoreKeeper.AddPoint();
     }
 }
コード例 #2
0
 void OnCollisionEnter2D(Collision2D other)
 {
     if (other.gameObject.name == "Player")                                   //if this object colides with the other object named Player
     {
         AudioSource.PlayClipAtPoint(Jump1, transform.position);              // Play jumping sound
         scoreKeeper.AddPoint();                                              // Add points to score in ScoreKeeper
         other.gameObject.rigidbody2D.AddForce(new Vector2(0.0f, jumpForce)); // Push the Player upwards like a jump
         gameObject.SetActive(false);                                         // Set the platform as inactive in the hierarchy
     }
 }