Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Heloo help me pls

Discussion in 'Scripting' started by branek42, Jan 20, 2015.

  1. branek42

    branek42

    Joined:
    Oct 10, 2013
    Posts:
    76
    I need advice with one script , script is a touch Gameobject :

    I click on gameobject score then added and subtracted bullet picture but add double and triple score and subtracted double and triple bullet picture


    Code (JavaScript):
    1. var  ClickScore : float;
    2. var bullet2 : int ;
    3. var toggle : boolean = true;
    4. var sound: AudioClip;
    5.  
    6. function Update ()
    7.      {
    8.        bullet2 = bullets.bullet;
    9.    
    10.        if (toggle == true){
    11.    
    12.        if (Input.touchCount > 0)
    13.        {
    14.            var ray = Camera.main.ScreenPointToRay (Input.GetTouch(0).position);
    15.            var hit : RaycastHit;
    16.         if (Physics.Raycast (ray, hit))
    17.        {
    18.          Debug.Log(" You just hit " + hit.collider.gameObject.name);
    19.         if(hit.collider.tag == "Parrot")
    20.         {
    21.          if (bullet2 > 0 ){
    22.          AudioSource.PlayClipAtPoint(sound, transform.position);
    23.      
    24.          bullets.bullet -= 1;
    25.      
    26.          LevelsScore.score += ClickScore;
    27.          LevelsScore.totalscore += ClickScore;
    28.          Destroy(hit.transform.gameObject);
    29.         }
    30.        if (bullet2 < 1 ){
    31.           toggle = false;
    32.         }
    33.        }
    34.       }
    35.      }}}
     
    Last edited: Jan 20, 2015
  2. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Use descriptive topic titles.
     
  3. branek42

    branek42

    Joined:
    Oct 10, 2013
    Posts:
    76
    Can you send me a link pls ? Can not Find It
     
  4. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
  5. branek42

    branek42

    Joined:
    Oct 10, 2013
    Posts:
    76
     
  6. BenZed

    BenZed

    Joined:
    May 29, 2014
    Posts:
    524
    Yikes.
     
  7. BenZed

    BenZed

    Joined:
    May 29, 2014
    Posts:
    524
    @branek42 you have a major communication failure going on here.

    Go back, re-read what you wrote and try to describe your problem in greater clarity and detail. Add comments to your code, as well, because as it stands now it's too messy to warrant reading.

    Spellcheck doesn't hurt, either.
     
  8. branek42

    branek42

    Joined:
    Oct 10, 2013
    Posts:
    76
     
  9. branek42

    branek42

    Joined:
    Oct 10, 2013
    Posts:
    76
    If you click on Gameobject add with the two score
    ( LevelsScore.score+= ClickScore; and LevelsScore.totalscore+= ClickScore; )

    ClickScore = 100 but add 200 or 300 or 400


    next If you click on Gameobject deletes one bullet picture from script bullets
    (bullets.bullet-=1 )

    but delete 2 or 3 or 4 of 7 bullet image

    help me thank
     
  10. Nubz

    Nubz

    Joined:
    Sep 22, 2012
    Posts:
    553
    A descriptive post would have been nice also.
     
    BenZed and Kiwasi like this.
  11. branek42

    branek42

    Joined:
    Oct 10, 2013
    Posts:
    76
    helps pls someone?
     
  12. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Multiple people have responded, all who are capable of fixing your problem.

    No one understands what you problem is. Please reread your problem and restate it more clearly. If English is not your native language then have a native English speaker read over it for you.
     
    BenZed likes this.