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 Sanosake1 · Jan 23, 2012 at 04:42 AM · rigidbodyinstantiatebullet

Bullet hell - how to make a lot of bullets?

Hello,

this is my first post here so bare with me. I am currently attempting to create a 3d bullet hell game. In this game i want to generate a lot of projectiles of varying sorts that are emitted from varying sources. I have tried using instantiate and destroy to create and kill physical (rigidbodied) bullets, but once I get a few sources on screen firing at once, I experience severe slow down. Any thought on how to fix this would be very appreciated!

Comment
Add comment · Show 2
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 Fattie · Jan 23, 2012 at 10:40 AM 1
Share

that's "bear" with me. not "bare".

it's the same word as "bearing a load" or "ball bearing".

Just click "Edit" to fix !

avatar image Sanosake1 · Mar 06, 2012 at 09:19 PM 0
Share

Damn spelling nazi! Done :P

3 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by IgnoranceIsBliss · Jan 23, 2012 at 04:53 AM

You don't really need physics for a bullet hell game - they just travel in a straight line until they smack into something. I think you could save a LOT of processor time by making your own really basic behaviour to keep your bullets moving.

At the moment you'll be calculating all kinds of things you don't need. I'd say 'Keep It Simple'.

So store the Vector3 that is the direction and speed it was shot in, then simply multiply that every frame. So off the top of my head...

   public Vector3 Velocity;
 
   void Update()
   {
       transform.Translate(Velocity * Time.deltaTime);    
   };

You'll also need to add collision detection of course, but this basic example SHOULD have you with a particle that keeps travelling in the direction it was fired and is MUCH less complex than a RigidBody.

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 Sanosake1 · Jan 23, 2012 at 06:04 AM 0
Share

This boosted my fps DRA$$anonymous$$ATICALLY! THAN$$anonymous$$S!

avatar image
2

Answer by Kiloblargh · Mar 06, 2012 at 11:00 PM

Don't use Instantiate at all if you can avoid it, and certainly not to instantiate bullets in a game of this type. Use an object pool script. There is one ObjectPool.cs, written by Invulse, that you can find on the forum and is free to use as is or modify. It goes in the "Plugins" folder, not "Scripts".

You just need to set the position and rotation of the object in the next line, and make sure you reset whatever needs to be reset on the bullet before calling PoolObject to dispose of it.

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 Zach3ryH · Dec 30, 2013 at 08:54 PM 0
Share

Totally agree. I am not sure if this script happens to disable the object, but if you disable them when you add them back in the pool it prevents any unnecessary update calls to those game objects.

avatar image
0

Answer by potatoking · Dec 30, 2013 at 09:04 PM

You could also use particle systems instead of instantiating objects

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

8 People are following this question.

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

Related Questions

My 2d spawned bullet prefabs will not fly up, just fall 3 Answers

Bullet always facing the sky. 3 Answers

Instantiate rigidbody C# 1 Answer

OnCollisionEnter not triggering when two rigidbody collide via Instantiate 1 Answer

Applying force to a rigidbody 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