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 coolbird22 · Aug 18, 2014 at 08:45 PM · 2dterraintiledestructible

How to create destructible tile based 2D terrain like 'Broforce' does ?

There seems to be a particular number of bullets(damage) that each tile can take before being destroyed. There also is a blast radius of the bomb that destroys all the tiles in its' vicinity. What aspects of Unity do I need to look into, to achieve such destructible and crumbling effects ?

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

2 Replies

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

Answer by error031 · Aug 18, 2014 at 09:28 PM

I think you should make script and attach to tiles that holds number of times you shooted at that tile. Something like:

tileLogic.js

 var tileHealth : int;
 
 function Start() {
    tileHealth = 3; 
 }
 
 function Update () {
    if(tileHealth == 0){
       Destroy (gameObject); 
    }
 }
 
 function OnCollisionEnter2D(coll: Collision2D) {
     if (coll.gameObject.tag == "Bullet")
         tileHealth--;

     if (coll.gameObject.tag == "Bullet")
         tileHealth-=3;
 
 }

In this case you should have colliders2d on tile, bullet and bomb (size of the radius).

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 coolbird22 · Aug 23, 2014 at 05:46 PM 0
Share

Thanks for sharing. This worked just fine.

avatar image
2

Answer by Cherno · Aug 18, 2014 at 10:31 PM

You declare a 2-dimensional array which holds the integrity values of each block.

 var world : float[,] = new float[worldSizeX, worldSizeY];

If a tile gets damages, you just decrease the float value at the coordinates.

 world[2,6] -= damage;
 if(world[2,6] <= 0.0f) {
      //some kind of destruction effect?
 }


Getting all tiles in a radius should be easy, just use a nested loop with x - 1 to x + 1 and so on.

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 coolbird22 · Aug 23, 2014 at 05:46 PM 0
Share

Thanks for sharing. That might just work.

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

24 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 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

Collision with Texture when alpha=1 1 Answer

How would I go about 2D tile-based procedural generation? 0 Answers

Creating 'worms'-like terrain 1 Answer

How to create a ground/terrain/floor that won't respond to gravity or objects falling on it? 1 Answer

Randomizing tile textures 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