- Home /
Problem at add Score+1 When Pass rocks
using UnityEngine;
public class Player : MonoBehaviour { public Transform skor; private int score=0; private bool GuiOn=false,bisa=true; public GUIStyle template;
 // The force which is added when the player jumps
 // This can be changed in the Inspector window
 public Vector2 jumpForce = new Vector2(0, 300);
 
 // Update is called once per frame
 void Update () 
 {
     if (bisa) 
     {
     skor.guiText.text = score.ToString ();
     // Jump
     if (Input.GetKeyUp("space"))
     {
         rigidbody2D.velocity = Vector2.zero;
         rigidbody2D.AddForce(jumpForce);
     }
     if(Input.touchCount > 0) {
         for (int i = 0; i<Input.touchCount; i++) {
             if (Input.GetTouch(i).phase == TouchPhase.Ended)
             {
                 rigidbody2D.velocity = Vector2.zero;
                 rigidbody2D.AddForce(jumpForce);
                 }
             }
          }
      }
  }
 void OnCollisionEnter2D (Collision2D col)
 {
     
     if (col.gameObject.tag == "rock Pair") {
         GuiOn=true;
     } 
 }
 void OnPolygonEnter2D  (PolygonCollider2D col) {
     if (col.gameObject.tag == "score") {
                     Debug.Log ("scoooooooooorrrrreeeeeee");
                     score += 1;
             }
     }
}
How i to do to add Score+1 When pass rock ? What in My C#scripts is False?
How C#script is True Please Repair My C#scripts
Please Help Mee
               Comment
              
 
               
              Do you get an Errormessage ?
And do you attached the correct tags to the Objects ?
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                