player pick up bomb

This hase been refraised from making a search and destroy mode to picking up a bomb. Here is my code.

private var Player : Bomb;

function OnTriggerEnter(collision : Collision)
{
    if ( collision : Collision )
    {
        Destroy ( GameObject );
        if ( Player )
        {
            Player = GetComponent(Bomb) += 1 Bombs;
        }
    }
}

I have accapted a answer.

This is not the kind of question to ask here. This site is for very specific questions such as "Why does this code not work" etc. No one is going to write multiple scripts for you.

If you haven't already I would check out the tutorials at the tutorial page Also check out Unity Student for lots of mini tutorials on techniques you will use often in any type of game.

What alot of people meant in the first answer is that you get much better results when you break your question into lots of little questsion and post them in different questions. You complained about not really getting an answer, but untill you posted the code, you had not actually asked any question.

There are alot of things wrong with your code. I have gone through your script and added in comments explaining what you did wrong and how to do it correctly. Hopefully it will be a learning experience. If you make the changes it wont necessarly work, becuase as I mention in my comments, I am not entirely certain what you are trying to acomplish.

I won't write the code for you, but am willing to help guide you towards writting it youself (feel free to comment with any questions). Hope this helps.

I am assuming from your wording that the first script was in your player.

    /*This line creates a variable called player. The section after teh ':' is setting the type of variable. You are saying that the Player variable is goign to refer to a bomb. However, you never set it equal to anything and by making it private make it so that it is imposible to set through the editor. I'm not sure exactly what you were wanting to use the variable for.*/    
    private var Player : Bomb;

    /* when defining the function the stuff in the parentheses name the arguments that are being passed to it. the 'OnTriggerEnter' function is automatically passed an argument of type Collider. the section in the parenthesses should read 'collision: Collider' Basically it is saying that within the function the collider that set off the triger will be refered to as 'collision'*/    
    function OnTriggerEnter(collision : Collision){
     /*An if statement checks if something is true. It evaluates something like 'x==y'. When only a single term is in the statement it looks at it as true/false. 'collision:Collision' is not really saying anything. The 'variableName:variableType' is only used when declaring variables. I am assuming you want to check if the thing triggering it is a bomb. If so you could use 'if(collision.tag=="bomb")' You would need to make sure that bombs are given a tag saying 'bomb.' when you have a something like 'component.variable' or 'object.variable' you are accessing a variable that is part of an object or component. This is an important part of Object oriented programing, and I will refrence it again in a bit */
if ( collision : Collision )    {
            Destroy ( GameObject );
/*When you you use the destroy command it will destroy whatever object is refered to by the variable within the the parentheses. In the script refrences you will see it written as you wrote it above because it destroys gameobjects. You will want to make sure you are refereing to a specific object. 'Destroy(collision)' will destroy the object that has been collided with (the bomb)*/
            if ( Player )        {
/*I'm not sure what this is supposed to be doing. Player is the variable you defined at the beginning. It is undefined at this point, and you have defined it as type Bomb. If you want it to be a true/false type thing you will need to define it as a boolean*/
                Player = GetComponent(Bomb) += 1 Bombs;
/*I am assuming here you want to increase the number of bombs the player wants to have. If the player has a script called Bomb attached to them, then GetComponent will work. If this script IS the one called Bomb, then you dont need the GetComponent. You would however want to define a variable called 'bombs' at the beginning (I used lowercase because of convention. So if you have a seperate script called Bomb with a variable bombs you could use 'GetComponent('Bomb').bombs += 1;' if this is the script called Bomb you can just do 'bombs+=1;'*/
            }
        }
    }

It was unclear to me if the second script was your player scripts called Bombs or a script attached to your bombs. There are a couple mistakes. One thing is that update is called every frame. So if the player is running the script he is constantly resetting his bombs variable to zero. The other thing is that Unity is case sensative. 'bomb' and 'Bomb' will be seen as two different things.