Bomb Script for 2d space shooter

Greetings, my name is Tim. I got a project in school and to get to the higher grades I need to create a script for a bomb for a space shooter game. I also see this as great practice because I will be starting to create games on my own in unity soon enough. Knowing how to make an okay script would be pretty helping ^^

So, I want to create a script for a 2d space shooter game. I already created the bomb in maya/photoshop, and imported it into unity. Then I also added a java script to it and the only thing left to do is to edit the script. This is what I don't know how to do. I dont know how to script but I would love to learn.

Bomb functions: The bomb should spawn at a random position in X and go towards -y (bottom) and if this bomb colide with the player bullet (if the player will shoot at the bomb) the bomb shall explode, doing a very simple anymation since I'm only interested in the scripting part. When the bomb explode every enemy on the screen shall also be destroyed. Since it is a bomb :) If the player dont shoot at the bomb and the bomb travels part the screen it shall disappear.

If anyone could help me create this script It would be awesome! Giving me hints on tutorials, or just step to step on how to do it in person would be great aswell. I will be using the search functions while waiting for answers but I think I will get better answers here than out in the infinit space of the internet. That is why I created this thread!

So help me take this first step into scripting in unity, to create my first script! Be the one that I shall remember that helped me create my first script! hehe

Thanks in advance//a future unity user! --> Unity3D official forum site --> Community site stack exchange

For C# and Jscript -->

To move object change the transform with the Translate method using the . operator to acces it's method. As such:


Due to the nature of the script being on the object itself ( bomb ) the transform property already references (points at) the bomb so the system will understand you mean you want to change that specific object.

Vector3.down is an existing Vector, to make your own I only know for sure in C# that u need to use the new Keyword as such:

Vector3 (composed of 3 floats -->) and f (floating point number, e.a. decimal numbers such as 0.0 -1.2 or 3.14) represent datatypes, something u CAN do I think in Javascripting but you can just toss var in front of everything and declare with : , but I am a noob at javascript so don't expect much there ;) just trying to explain some common stuff give you some links etc.

Vector3 left = new Vector3(1.0f, 0.0f, 0.0f);


Vector3 left;

//The Monobehaviour start script , it's a monobehaviour 
//if you CAN stick it on something in the unity3D editor basically.
void Start()
   left = new Vector3(1.0f, 0.0f, 0.0f);

//Called once per frame, use this method to do stuff all the time
//So doing transform.Translate(Vector3.up) here would make the object 
//go up forever, no more no less
void Update()



You will be able to find all the Unity3D engine functions in here. And some words of wisdom, when u learn programming, u actually have to program. Reading 500 scripts and 10000 tutorials makes u well read, but not a programmer. And that way you will miss a lot of important details you only learn from experience and first hand action.

And please feel free to ask me whatever, I won't make any promises but I'm here a lot these days :) So please feel free to do so!

Good luck with the work.

(And yes I intentionally didn't write your script, go DO it remember ^^)