Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 zerox911 · Jun 20, 2012 at 08:21 AM · multiplebulletsprojectiles

shooting multiple projectiles at enemies

hi again..

i need some help on this topic here...

i'll post a youtube link and describe it as well...

http://www.youtube.com/watch?v=C4iO1Gl7wiA

its from Tom Calancy's HAWX..

i want to create multiple bullets/ missiles/ etc.. to my space ship..

similar to the youtube clip..

does anyone have any ideas on doing this??

thanks for reading.. and your patience is highly appreciated..

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 hijinxbassist · Jun 20, 2012 at 08:48 AM

All shots are 'instances' meaning a "shallow copy" of the original. They reference the same /mesh,position,rotation,etc/ of the original but will not be as costly as a "New" version of that prefab. In this case you will have one MAIN version of the shot (var myRocket) which can now be used in (var rocket=Instantiate(myRocket,'somePosition',Quaternion.identity) which makes the shallow copy, not quite as processor intensive as creating that same object from scratch with the same mesh,position,rotation as the original. In doing so you create a new way for unity to look at this "new" object(reference to the original), instead of looking at it as a completely new object entirely. This save speed and lines of code, and will be able to create 10 instances faster than 1 new org object of the same type.

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 hijinxbassist · Jun 20, 2012 at 08:54 AM 0
Share

If you are shooting on one script...say something like the previous idea

 var myRocket:Transform;
 
 function Shoot()
 {
     var rocket=Instantiate(myRocket,transform.position,Quaternion.identity);
 
     //rocket.doSomethingElse;
     //$$anonymous$$aybe make a var on rocket true, or speed faster, or any number of things
     //be creative but be logical in doing so(fill Shoot overload with speed etc..
 }
avatar image zerox911 · Jun 20, 2012 at 09:18 AM 0
Share

thanks... i'll try it.. but i need some more reference and some snippet codes or something..

appreciate it @hijinxbassist..

avatar image hijinxbassist · Jun 20, 2012 at 11:18 AM 0
Share

Since you dont have any code in your questions its tough to guess the proper coding technique. This is a basic structure which i provide, here is a little more on top of that..again tough to give specifics w.o actually code present

 //On Player
 //cur shot is deter$$anonymous$$ed from a series of actions
 //the cur shot may be 1,2,3,etc if the weapons are
 //set as so(maybe) add(if input getButton(1) curShot="SomeShot")
 //i cant be more specifice w.o specific code
 //canFire is a boolean to dealy shot time(if true plr can shoot)
 
 function Update()
 {
      if(Input.GetButtonDown("Fire")
      {
          if(canFire)Shoot(curShot,2);
      }
 }
 function Shoot(shotType:Transform,shotLife:float)
 {
     var shot=Instantiate(shotType,transform.forward,transform.rotation);
     shot.GetComponent(Shot).shotLife==shotLife;//$$anonymous$$akes the shotLife 2
     //granted shotType has a Comonent(Shot) and a variable called shotLife
     //the basic idea is:(shotLife==how long shot is active in scene)
     //which is define on a separate script(Shot) which is attached to
     //the curShot(a variable which may change, num1=pistol, num2=shotgun)
 }

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Deleting Bullets after a few seconds 2 Answers

Visible Bullet Tracers and Lasers Clarification 1 Answer

How can I fire bullets at mouse position 1 Answer

Deleting Multiple Bullets after Set Time 1 Answer

Window (not full screen menu, etc.) over parent window (as WinForm) with full autiscalling depend of screen size with resize bacground photo of this parent window to size of this parent window 0 Answers


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