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 stx-visuals · Mar 01, 2015 at 09:58 AM · 2dphysicsbomb

Explosion in 2d - scripting practices, speed, multiple explosions

Hi! I am implementing explosion system to my 2d game, I think there should be 2 ways how to approach this

the bomb will execute script that checks which objects are in radius, then calculates the force to apply for each object and apply it. When i did this, only way i found was to iterate through the list of objects, which is very slow, how to do it fast?)

second method is to broadcast event from the bomb, every object then checks if it is in radius, then calculates and apply force on itself, i managed to do this without any problems, but it does not feel like best solution

my question is, what do you think would be best way to do this? I can think of combination of these two, (bomb checks for objects, then attach explode script to them which will destroy itself afterwards)

my concerns are, what happens when 2 bombs explode on same frame close to themselves, and how to do it fast, so overall design simplicity and niceness :)

Comment
Add comment · Show 1
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 meat5000 ♦ · Mar 01, 2015 at 02:54 AM 1
Share

Include a layermask in your OverlapSphere so you dont end up trying to affect things like the terrain. I believe it makes more sense for the bomb to do the work ins$$anonymous$$d of having multiple objects all perfor$$anonymous$$g checks.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Greek_Soldier · Mar 13, 2015 at 12:25 PM

What if you made an explosion function and used OverlapCircle with a layermask that filters out bombs and other things that you don't want to effect? Than, you instantiate an explosion prefab at there position before destroying them. The explosion prefab could have a similar script attached to them if you wanted a chain reaction.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Help with orbits 1 Answer

Objects stuck dragging across floor 1 Answer

Calculate initial velocity for projectile to reach point at a given angle and calculate angle to reach point at a given velocity. 1 Answer

2D Joint/Wheel Question 1 Answer

CharacterController 2D Move called on inactive controller but it is active... 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