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 Marvin Hawkins · Sep 25, 2010 at 08:11 PM · bulletshootershmuphell

How do I create bullet patterns (multiple bullets, different world positions)

Hi,

I'm trying to create enemies that create bullet hell shooter patterns. These require multiple bullets to be fired in circular or arc patterns at once. My simple question is what is the best way to go about this?

should I:

1) Script an enemy with multiple bullet "gameobject" and then instantiate them in code, once the player is close?

2) Should I put all bullet objects into one prefab and then instantiate that prefab in code. (I tried this, and for some reason, prefabs don't like object with duplicate names.)

Not sure if either of these is the best way. But neither has worked properly. Option 1 creates two bullets in the same position; which makes it look like just one bullet has instantiated.

I appreciate any input you have. Please let me know if clarity is required.

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

3 Replies

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

Answer by Billamu · Sep 25, 2010 at 09:52 PM

This piece of code will do it. It's not fancy but it does the job.

var bullet : Transform; var bulletAmount : float = 8; private var bulletcoords : Vector2; private var rot : Quaternion;

function Start() { for (var i : float = 0; i<bulletAmount; i++) { rot.eulerAngles = Vector3(0,270+((i/bulletAmount)*180),0); Instantiate(bullet, Vector3.zero, rot); } }

What I discovered while coding this is that my variables needed to be floats, not ints; otherwise the division of i/bulletAmount doesnt work.

http://unity3d.com/support/documentation/ScriptReference/Quaternion-eulerAngles.html

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 Marvin Hawkins · Sep 26, 2010 at 05:17 PM 0
Share

Thanks for your help Bill. Is there any place I can find more info on While loops and for loops in Unity?

avatar image
0

Answer by vestax_ion · Jul 13, 2011 at 07:30 PM

I am learning code, i wanted to figure how to make the bullets change position as well as rotation, the answer was to change the instantiate line to:

Instantiate(bullet, Vector3(0, i ,0), rot);

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 Chris D · Jul 13, 2011 at 07:37 PM 1
Share

This is not an answer and should not be posted in the answers section.

If you have a question, open a new thread and link to this one for clarification.

avatar image vestax_ion · Jul 13, 2011 at 07:45 PM 0
Share

so i get -4 on this forum for asking about a line of code posted in a thread, within the same thread?

avatar image Chris D · Jul 13, 2011 at 08:08 PM 1
Share

You're right, that was harsh (I get cranky before lunch...).

Fixed it, but ya, reserve the answers section for answers.

avatar image
0

Answer by spinaljack · Sep 25, 2010 at 09:36 PM

You could have a "shooter" game object that is just an empty game object that sits where the bullets appear from.

Instantiate a bullet each frame and rotate the object by some amount using rotate

Keep firing and rotating for as many frames as you want to fire for.

You can also use for loops to fire and rotate multiple times in a single frame.

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.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

All Three Game Objects Fire At Once 1 Answer

Bullet Pattern for Bullet Hell 1 Answer

Shmup style enemy behavior 0 Answers

how to make bullet ascend/descend relative to uneven ground level? 2 Answers

2D Bullet Hell Game - Bullet Patterns 2 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