Search Unity

non responsive booleans

Discussion in 'Scripting' started by Nightshade1, Feb 26, 2012.

  1. Nightshade1

    Nightshade1

    Joined:
    Feb 6, 2011
    Posts:
    95
    i made this and it should have worked but the booleans dont work not allowing the script to work
    Code (csharp):
    1.  
    2. function OnCollisionEnter (collision : Collider) {
    3.     if(collision.transform.name=="ballred")
    4.     redcol = true;
    5.     StartCoroutine("EndLevel");
    6. }
    7.  
    8. function OnCollistionExit (collision : Collider) {
    9.     if(collision.transform.name=="ballred")
    10.     redcol = false;
    11.     StopCoroutine("EndLevel");
    12. }
    13.  
    14. function EndLevel() {
    15.     yield WaitForSeconds(3);
    16.     if(redcol)
    17.     {
    18.      gameObject.Find("ballblue").AddComponent(Rigidbody);
    19.     }
    20. }
    why is it not working??
     
  2. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,699
    Maybe ballred does not exist. Double check its name in the heirarchy.
     
  3. Nightshade1

    Nightshade1

    Joined:
    Feb 6, 2011
    Posts:
    95
  4. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,325
    No. collision.name

    No. GameObject.Find

    Your if statement indentation is also ambiguous.
     
  5. Nightshade1

    Nightshade1

    Joined:
    Feb 6, 2011
    Posts:
    95
    still does not work can i just get the complete script?
     
  6. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,325
    It's your script. Nobody else has it.
     
  7. unknows

    unknows

    Joined:
    Sep 5, 2010
    Posts:
    51
    Last edited: Feb 26, 2012
  8. unknows

    unknows

    Joined:
    Sep 5, 2010
    Posts:
    51
  9. DanielQuick

    DanielQuick

    Joined:
    Dec 31, 2010
    Posts:
    3,137
    OnCollisionExit

    not

    OnCollistionExit
     
  10. unknows

    unknows

    Joined:
    Sep 5, 2010
    Posts:
    51
    ops another mistake post. sorry.
     
  11. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    also...

    function OnCollisionEnter (collision : Collision)

    not collider