• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by Tim 1 · Nov 16, 2010 at 04:38 PM · 2dspacebomb

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!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by Proclyon · Nov 16, 2010 at 06:12 PM

http://forum.unity3d.com --> Unity3D official forum site

http://answers.unity3d.com --> Community site stack exchange

For C# and Jscript --> http://msdn.microsoft.com/en-us/library

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

transform.Translate(Vector3.down);

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);

or

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() {

}

MOST IMPORTANT OF ALL:

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.

http://unity3d.com/support/documentation/ScriptReference

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 ^^)

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Moving Up, Down, Left and Right via Wasd and the arrow btns?? in 2d 2 Answers

2D solarsystem lighting 0 Answers

Assets/Scripts/PlayerController.cs(32,49): error CS0126: An object of a type convertible to `float' is required for the return statement 1 Answer

How to make a 2d pixel art shader for a glass window that show outer space? 0 Answers

[2D] How to instantiate laser when player rotates? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges