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 samdogg7 · May 15, 2012 at 10:00 PM · fpszombiereplacedead

Help With Zombie

Hi, I am currently making a video game and was wondering how to make a dead zombie once shot till it dies. I have created all of the zombie AI and when they die though they disappear. I want them to not disappear but instead fall over (Ragdoll possibly so arms aren't straight out.) I tried this and successfully did it! but there is one problem i am using Spawner Free (Asset store) and they still disappear. Also is there a way to make blood spew out of the dead zombie (Not a ton but some to drip to floor.) AND Finally will it be laggy to have a ton of dead rag dolls every where? If so can i make it so they disappear after a certain amount of time?

TO summarize what i was asking for: Dead Replacement (Read more about it above to see why it is challenging) Blood for when object dies Delete dead zombie after certain time

edit moved code from comment

 var hitPoints = 100.0;
 var deadReplacement : Transform;
 var dieSound : AudioClip;
 
 function ApplyDamage (damage : float) {
     // We already have less than 0 hitpoints, maybe we got killed already?
     if (hitPoints <= 0.0)
         return;
     hitPoints -= damage;
     
     //THIS is character damage script... it works well with my zombie AI
     
     if (hitPoints <= 0.0)
     {
         Detonate();
     }
 }
 
 function Detonate () {
     // Destroy ourselves
     Destroy(gameObject);
     
     // Play a dying audio clip
     if (dieSound)
         AudioSource.PlayClipAtPoint(dieSound, transform.position);
 
     // Replace ourselves with the dead body
     if (deadReplacement) {
         var dead : Transform = Instantiate(deadReplacement, transform.position, transform.rotation);
         
         // Copy position & rotation from the old hierarchy into the dead replacement
         CopyTransformsRecurse(transform, dead);
     }
 }

 static function CopyTransformsRecurse (src : Transform,  dst : Transform) {
     dst.position = src.position;
     dst.rotation = src.rotation;
     
     for (var child : Transform in dst) {
         // Match the transform with the same name
         var curSrc = src.Find(child.name);
         if (curSrc)
             CopyTransformsRecurse(curSrc, child);
     }
 }


Thanks! Sam

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 Bunny83 · May 16, 2012 at 11:43 PM 0
Share

@samdogg7: Please don't post additional information on the question as answer. Edit your question or post a comment below the question. Answers should answer the question ;)

Also watch your code highlighting. Just select all text that should be displayed as code and press the "101 010" button. This will just indent each line by 4 spaces and insert an empty line before and after the code block. This could also be done manually, but with the button it's really simple.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Befall · May 16, 2012 at 08:24 PM

Blood's not terribly challenging depending on how you want it to look, it can be as simple as grabbing a spot on the ground below with a raycast, spawning a plane with a blood splat on it, and slowing extending it until it and the zombie are deleted.

For the deleting of the zombie, ragdoll or not, just have a dead bool in each of the zombie scripts that clocks time after death. Like this:

 void Update()
 {
     if (dead)
         deadTimer += Time.deltaTime;
     if (deadTimer >= 3)
         Destroy(gameObject);
 }

As for ragdoll functionality having an issue, I'd look around for people's tutorials/scripts that show how to do proper ragdoll replacement. gl hf!

Comment
Add comment · Show 4 · 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 samdogg7 · May 16, 2012 at 11:08 PM 0
Share

Thanks! but i still have the disappearing problem with the spawner because the transform object isn't there because it doesn't save the modified vars. Is there a way to delete the transform and place the name of the dead zombie prefab? I will post my code below...

avatar image Befall · May 16, 2012 at 11:53 PM 0
Share

So you're saying that since you creating a new Ragdoll, which has a different transform than the zombie, it doesn't know where that transform is, or doesn't destroy it?

It's all a bit confusing hehe.

avatar image samdogg7 · May 17, 2012 at 01:20 AM 0
Share

Basically i am using Spawner free, it is a excellent spawning system...except it will only spawn Prefabs... I have a death replacement file (The new separate zombie) But i can't have it save that transform to a prefab, thus then making it so you can't have a death replacement.

avatar image The-Arc-Games · Jul 03, 2012 at 07:21 AM 0
Share

Check out URG's free version in the asset store. It has a demo scene with a very easy to understand example to do what you need!

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

Multiple Cars not working 1 Answer

zombie ai script 1 Answer

I have some code for the zombie AI but.... 2 Answers

My gun wont fire ! 1 Answer

Hunger system help - Money to be made 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