• 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 AusAndrew19 · Jul 05, 2012 at 11:16 AM · fpsenemytag

How to make an enemy change tags after death.

Hi guys! My Unity3D Game is coming along nicely. Learning a bunch on the way! I was wondering is there anyway to make and enemy change its tag from "enemy" to "untagged" the enemy AI Script i have uses Health ofc is there a way to make it change tags if health reaches 0. The reason i want to ac$$anonymous$$eve t$$anonymous$$s is because the dead bodys are screwing my radar. If i could get any info on t$$anonymous$$s it would be muchly appreciated. Thank you all in advance.

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

3 Replies

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

Answer by syclamoth · Jul 05, 2012 at 11:35 AM

Very straightforward:

 gameObject.tag = "";

T$$anonymous$$s will remove the tag from the gameObject. Just drop t$$anonymous$$s into your 'death' function.

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 AusAndrew19 · Jul 05, 2012 at 11:43 AM 0
Share

Looks promising.... Only bad thing.. i cant find the death function now lolz... thanks for the help.

avatar image
0

Answer by Linus · Jul 05, 2012 at 11:35 AM

See http://docs.unity3d.com/Documentation/ScriptReference/GameObject-tag.html

After:

dead= Instantiate(deadReplacement2, GOPos.transform.position, GOPos.transform.rotation);

Insert:

dead.tag = 'newtag';

Tags must be declared in the tag manager before using them.

Comment
Add comment · 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
0

Answer by AusAndrew19 · Jul 05, 2012 at 12:00 PM

     ShotHead=true;
 }
 
 function ApplyDamage (damage : float) {
  if ($$anonymous$$tPoints <= 0.0)
  return;
  // Apply damage
  $$anonymous$$tPoints -= damage;
  scoreManager.DrawCrosshair();
  // Are we dead?
  if (ShotHead==true) {$$anonymous$$tPoints=0.0;Replace();}
  else if (ShotHead==true && $$anonymous$$tPoints >= 0.0) {$$anonymous$$tPoints=0.0;Replace();}
  else if (ShotHead==false && $$anonymous$$tPoints <= 0.0)Replace(); 
 }
 
 function Replace() {
  // If we have a dead barrel then replace ourselves with it!
  if (deadReplacement && ShotHead==true) {
  dead= Instantiate(deadReplacement2, GOPos.transform.position, GOPos.transform.rotation);
  scoreManager.addScore(20);
  // For better effect we assign the same velocity to the exploded barrel
  dead.rigidbody.velocity = rigidbody.velocity;
  dead.angularVelocity = rigidbody.angularVelocity;
  Destroy(gameObject);
     } 
     else {
     dead=Instantiate(deadReplacement, GOPos.transform.position, GOPos.transform.rotation);
  scoreManager.addScore(20);
  // For better effect we assign the same velocity to the exploded barrel
  dead.rigidbody.velocity = rigidbody.velocity;
  dead.angularVelocity = rigidbody.angularVelocity;
  Destroy(gameObject);
     }
  // Destroy ourselves
 
 }
 
 
 is my damage script. But i cannot seem to find where to place t$$anonymous$$s little code.
 
 gameObject.tag = "";
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 Linus · Jul 06, 2012 at 03:57 PM 0
Share

This can be done to the deadReplacement, attach a script (or edit an existing one) to the replacement prefab, and place the code there in an Awake function. Or see my updated answer

avatar image Linus · Jul 06, 2012 at 04:13 PM 0
Share

And please edit your code posted here into your question posting. And make sure to turn on code formatting on the code to make it easier to read.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

6 People are following this question.

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

Related Questions

Camera Recoil,Please help me. 2 Answers

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Shooting and health Help 0 Answers

Make the game stop if you get hit by enemy object 2 Answers

How to make a image flash infront of the camera 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