Destroyable environment

Updated on August 2, 2014 in [A] 2D
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
12 on July 26, 2014

Hi there!

I’d like to make a 2d platformer game where if the player shoots he can destroy objects ( like the entire terrain ). Much likely it can be seen on Broforce. If the payer dies the level resets to it’s original state. How can I do this? I just finished the basic course, currently done the parallax scrolling..so if this subject is covered in later courses just write down where 🙂 Thank you 🙂

  • Liked by
Reply
6 on July 26, 2014

Hi Cappie, if you want to restart your map when the player dies just Reload the Scene using the “Application.LoadLevel“.
(Remember to change the level name to the one of your scene)

//Load the level named "Map1"
Application.LoadLevel ("Map1");

on July 26, 2014

Thank you 🙂 Do you have any idea how to do the destroyable terrain? 🙂

on July 27, 2014

Probably an on collision event and when the bullet or projectile collides with an object it plays an animation waits for it to finish using tied waitforseconds then destroying the object hope this helps! 🙂

on July 27, 2014

Actually yes it helps ^^ I thought of something similar I will give it a try 🙂

on July 27, 2014

Great! 😀 so glad I could help

on August 1, 2014

You can also model your terrain in Blender and split it in debris with the plugin cell fracture.
In Unity you can destroy the parts of the terrain, where the player shoots at.

Wise
on August 1, 2014

Either create a fractured version of the object as suggested above, or deform the mesh.

Broforce’s terrain is made of perfectly square-shaped blocks, so deforming the terrain is as simple as Destroy()ing the block. (note that broforce also changes the terrain sprite, you’ll have to do that yourself)

Show more replies
  • Liked by
Reply
Cancel
1 on August 2, 2014

This tutorial is about destrubilble object in unity  so I suggest you to watch it , it wil teach how to do the cell fracture and other stuff that can help when you doing your destrucible object
here the link
https://www.youtube.com/watch?v=D6Ay4c6v9rs&list=PLbghT7MmckI6FPAZfn2HBdOu-JGSZ39vS#t=0

Wise
on August 2, 2014

You copied that link wrong, lol

Show more replies
  • Liked by
Reply
Cancel
1 on August 2, 2014
Guru
on August 2, 2014

Quill! I really like him, his tutorials and his let’s plays!

Show more replies
  • Liked by
Reply
Cancel
0 on August 2, 2014

something you can do is when something(tag it ‘ground’, maybe) is hit ( use collisions or ray casts to detect this), the sprite and collider of it is disabled. Then, have a script that monitors if you need to reset the level . When this happens all objects tagged ground (use FindGameObjectsWithTag(“ground”)) (GetComponent<GroundScript>()) will set their colliders and sprites as active (SetActive(true))

  • Liked by
Reply
Cancel