Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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
0
Question by DayyanSisson · Aug 01, 2011 at 05:52 AM · instantiatespaceshooterexplosionlaser

Shooting Lasers

I'm making a 3D space sim. What I need to know is how to create a laser, fire it, and make it explode when colliding with it's target. I've been looking around for a week now I can't find any scripts that work, even when I modify. Is there script that can help me? Thanks is advance

Comment
Add comment · Show 6
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
avatar image Chris D · Aug 01, 2011 at 06:32 AM 1
Share

Try starting with basic tutorials, then search 'laser' here and on Google. What you're asking is a multi-step process; it's not (unless someone's in a very giving mood) a simple plug and play solution.

avatar image DayyanSisson · Aug 02, 2011 at 06:17 AM 0
Share

As you can see, I said, "I've been looking around for a week now." To clear that up, I meant, on google, on unity answers/forums and on other websites

avatar image biohazard · Aug 02, 2011 at 07:07 AM 1
Share

Take a look at this : http://www.youtube.com/watch?v=ZQL$$anonymous$$EZzBIZE

avatar image DayyanSisson · Aug 02, 2011 at 05:15 PM 0
Share

Really, biohazard? Was that a joke?

avatar image Chris D · Aug 02, 2011 at 10:49 PM 1
Share

http://answers.unity3d.com/questions/133869/how-to-ask-a-good-question.html

Show more comments

3 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by DayyanSisson · Aug 04, 2011 at 06:24 AM

Ok. Now my problems have changed. All my "enemies" have damage receivers. Now, I need the lasers to damage to an object with a damage receiver. I also need to change the script where you can hold the button down and lasers shoot out continually. How should I write that in this script:

 var Laser : Transform;
 function Update () 
 {
     if(Input.GetButtonDown("Fire1"))
     {
         Instantiate(Laser, transform.position, transform.rotation);
     }
 }
Comment
Add comment · Show 1 · 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
avatar image save · Aug 04, 2011 at 06:40 AM 0
Share

Have you considered using a Particle System ins$$anonymous$$d with a World Particle Collider? It's far less intense than using this method.

avatar image
3

Answer by CHPedersen · Aug 01, 2011 at 06:32 AM

There's a script that can help you! In fact, there is one that does exactly, to the letter, what you want. But it doesn't exist yet, because, err... You haven't written it yet. ;-)

Poor humor aside, the tool you need to model your laser is the LineRenderer. Look into that, and then study the procedural example projects here:

http://unity3d.com/support/resources/example-projects/procedural-examples.html

Your question asks for a little much to begin with - firing something, drawing a laser, colliding with something, making an explosion, those are all different pieces of functionality, and the code that makes it work isn't even one script. Ideally, you'd split that stuff into several classes. So you gotta break your problem down, and tone down your expectations a little in the beginning. Start by seeing if you can draw something with the LineRenderer. Anything. Then if you can't come back and present your issues with it, and you can get help with that. Then when you understand how the LineRenderer works, start working on how to direct it from the player character in whatever direction he's firing. Then if you have problems with that, come back for help, etc, etc. etc.

The essence of what I'm saying is:

  1. Inspiration is fine. But you have to write your script yourself.

  2. Define milestones, then accomplish those, step by step.

Comment
Add comment · Show 3 · 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
avatar image DayyanSisson · Aug 01, 2011 at 04:54 PM 0
Share

I enjoy you're humor, thanks for the tip

avatar image FLASHDENMARK · Aug 03, 2011 at 08:34 PM 0
Share

I guess that "humor" comes with being Danish. :)

avatar image save · Aug 04, 2011 at 06:36 AM 0
Share

$$anonymous$$ade me smile this fellow neighbor of $$anonymous$$e. :-)

avatar image
0

Answer by fireDude67 · Aug 01, 2011 at 06:24 PM

I guess I am in a "Very Giving Mood"

What you need to do is:

  1. Model of Laser (Capsule is what worked for me, scale it by One axis until it looks like a laser)

  2. Texture the model - Create a new Material, then assign the Default color to Red, then drag it onto the Laser model

  3. Create a prefab with the Model - Create a new prefab, then drag the Laser model onto it.

  4. Add script that makes it go forward: New JavaScript -> add these lines:

              function Update() {
                    transform.Translate(Vector3.forward * Time.deltaTime);
                 }
    

5) add that script to your Prefab

Thats how you can create a laser. Later when I have more time i'll update for how to Fire the laser.

Comment
Add comment · Show 3 · 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
avatar image DayyanSisson · Aug 01, 2011 at 06:53 PM 0
Share

Thank's man.

avatar image nilesh026 · Oct 01, 2012 at 12:09 PM 0
Share

after fire laser how to detect collision pls tell and also how to stop it

avatar image programmrzinc · Mar 26, 2013 at 01:51 AM 0
Share

nilesh026 , simply call a Destroy.

 //Collision Just Happened.
 Destroy(gameObject);
 
 

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.

Follow this Question

Answers Answers and Comments

12 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Scrolling space shooter - making enemies drop currency 1 Answer

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

asteroids make framerate dip after too many have been created 1 Answer

Instantiated object multiple times in the hierarchy 2 Answers

Checking if object intersects? 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