How to fire a projectile and bring down a building

I know im copying battlefield 4, but in one of my levels, there is a building. i already have the falling down animation, but i need a script for firing a missile at the building, than after a few shots, it plays the animation and brings the building down. Please Help!

Well, we’re not going to give you a script, but here is how it can be done…

  • Make a trigger on the building using a box collider and make the building a certain tag
  • Make a script that plays the animation when the bullet/missle projectile enters that buildings’ collider that is set to trigger.

As for the few shots part, you can use a count system/point system for this, pretty easy stuff to learn. But this is the basic idea. Also, you want to make sure the animation is set to “Clamp forever” so the building does not collapse more than once.

Answers isn’t the place to ask for a completed script. It’s to help with a specific sticking point.

So, break down your problem. Have you tried to do any of the following?

fire a weapon when a button is pressed
have a weapon fire a missile
detect when that missile has hit a destructible building
track the amount of damage that has been inflicted
make an animation play when some condition is met
update the environment to reflect the collision state of the collapsed building

Try to do these things individually first. If you are having issues with any of these, ask about them specifically and mention how you went about it and what part didn’t work.

Thanks it helped a little, but i dont know how to code. it would be nice if you gave me a script, but a link to a place would be also helpful. Thank you though!