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 JokerMartini · Jul 17, 2012 at 12:59 AM · particlesexplodehealth

Explode object after being shot based on health decreasing (particle explosion)

I'm new the unity world and I'm a rather experience scripter in other languages but aside from that I was hoping that someone would be able to point a new member of the UND community in the right direction.

I simply want to take an object which has 100% health and have it's health deteriorate base on X number of shots/hits, and when its health equals 0% it will then explode using a particle system of some sort. I'm looking for a tutorial or sample/example of this exact creation, as from there I can pick up and learn from it. If it's easier for someone to share a super simple example scene of just a sphere exploding upon X number of shots/hits that would be greatly appreciated. Any help is great and I look forward to becoming a contributor and frequent member of the community here at UDN.

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 JokerMartini · Jul 17, 2012 at 02:00 PM 0
Share

How do i know when people post comments if they are done in c# or java?

I'd like to develop my game using c# as its something I want to learn in the process.

1 Reply

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

Answer by Piflik · Jul 17, 2012 at 01:14 AM

You'd need a health variable with a certain value. Then you add a OnCollisionEnter or OnTriggerEnter function and test if the colliding object is a projectile and if so decrease the health value by the projectile's damage. Lastly you test if the health is smaller than 1 and then instantiate a particle system and delete or deactivate the player.

Example (the actual script I am using in my game - minus some stuff that wouldn't help and might even confuse):

 function OnTriggerEnter(item : Collider) {
     if(item.tag == "Projectile"){
         if(item.GetComponent(Projectile).owner != "player" && !shieldActive && !invincible){
             PlayerStatus.plHealth -= item.GetComponent(Projectile).damage/PlayerStatus.multiplier;
  
             if(PlayerStatus.plHealth < 1 && !plDead) {
                 Instantiate(deathFX, transform.position + Vector3(0, 15, 0), Quaternion.identity);
                 plDead = true;
                 PlayerStatus.lives--;
  
                 statics.playerActive = false;

                 yield WaitForSeconds (1.5);
  
                 respawn();
  
                 if(PlayerStatus.lives < 1){
                     GameObject.FindWithTag("MainMenu").SendMessage("gameOverFN"); //GAMEOVER
                     plDead = false;
                 }  
             }
         }
     }
 }
Comment
Add comment · Show 2 · 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 JokerMartini · Jul 24, 2012 at 12:58 AM 0
Share

Do you know of any good tutorial or youtube videos that would explain so supply this in its most simplest form. In my case, an example of a sphere with a 100% health which gets hit by a projectile that does a damage of 35 percent. So the sphere dies in 3 hits. I'd love to see how this is done. I'm not sure how to set up projectiles or and object with health yet and that is what I'm looking to learn how to do. I've got all my objects set up which I want to have health.

avatar image Ranger-Ori · Jul 24, 2012 at 08:28 AM 0
Share

Look for TornadoTwins in youtube, they have a 40 videos tutorial for creating a shooter type game.

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

7 People are following this question.

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

Related Questions

Blocking particles then destroy then reduce health 0 Answers

How do i implament health using a particle system? 2 Answers

Particle system: Explosion, pause, then implosion 0 Answers

Particles shrinking whenever camera gets too close? 1 Answer

Particle System(Shuriken) optimization problem 1 Answer


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