- Home /
 
 
               Question by 
               BuzzardRaze765 · Jan 03, 2019 at 10:39 AM · 
                booleanconditionexpressionstatements  
              
 
              I can't move my spawned ball after i put Else If statement
i have a script, but i've got major problem.i was making a color game, and here's the script for the player:
 public class BallMovementYellow : MonoBehaviour {
 
     public float speed = 0.5f;
     public float camLimitX;
     Rigidbody BallRB;
     public GameManager GameStatus;
     public static bool hasStopped;
     public GameObject EndPanel;
     public float DestroyTime = 1f;
 
     // Use this for initialization
     void Start () {
         hasStopped = false;
         EndPanel.SetActive (false);
     }
     
     // Update is called once per frame
     void Update () {
         FallMovement ();
     }
 
     void FallMovement(){
         if (hasStopped == false) {//while game is still running
             Vector3 myPos = transform.position;
             myPos.x = Mathf.Clamp (myPos.x, -camLimitX, camLimitX);
             float h = CrossPlatformInputManager.GetAxis ("Horizontal");
             transform.Translate (h * speed, 0, 0);
 
         }
     }
         
     void OnTriggerEnter(Collider other){
         if (other.gameObject.name =="Yellow") {//Collide to same Color
             Destroy (gameObject);
             ScoreText.ScoreValue += 1;
         }/*else if (other.gameObject.name != "Yellow"){//Collide to different Color
             hasStopped = true;
             FindObjectOfType<GameManager>().EndTheGame();
             EndPanel.SetActive(true);
         }*/
     }
 
 }
 
               The Problem is that, everytime it spawn, it can't move, as it looks like it fulfills the Else If Statement. that's why i just hid the Else If Statement Here's the Ball Spawning script
 public float rate;
     public GameObject[] PlayerBall;
     public int wave;
 
     // Use this for initialization
     void Start () {
         InvokeRepeating ("Spawning", rate, rate);
     }
     
     // Update is called once per frame
     void Update () {
         
     }
 
     void Spawning(){
         for (int i = 0; i < wave; i++) {
             Instantiate (PlayerBall [(int)Random.Range (0, PlayerBall.Length)], new Vector3 (Random.Range (-4,4),9,0), Quaternion.identity);
         }
     }
 }
 
               Can Anyone Help me out? i still created these script with my basic coding understanding and translation skill.
               Comment
              
 
               
              Try debugging the object it collided with. Don't forget to Collapse/Uncollapse the console messages as needed.
 void OnTriggerEnter(Collider other) {
     Debug.Log (other.gameObject.name);
     return; // Skips the rest of the code
     
     // (Rest of your code)
 }
 
                 Your answer