Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 PlatPlayz · Jan 22, 2018 at 06:44 PM · 3ddestroydoorwall

Walls with doors in Unity3D

Hello! I've been trying to make an enemy come out of a door and then follow the player. It has to follow the player, and if the player dodges it, it has to hit a wall. I've got all the dodging and following sorted out thanks to this site, but here is the problem. I use a Plane as a wall. I want the enemy come through it, but I can't because if the enemy touches the wall, it gets destroyed. Is there a way to prevent this from happening?

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

1 Reply

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

Answer by bhavinbhai2707 · Jan 22, 2018 at 07:01 PM

Just set a bool in a script called shouldbeDestroyed = false; and once the Enemy passes the door and all animations and sort of stuff is done then simply make that bool true i.e, shouldbeDestroyed = true; and once the bool is true then only make the enemy destroyable

 if(shouldbeDestroyed)
 {
       DestroyEnemy();
 }
 
 void  DestroyEnemy()
 {
      //your code that controls and destroys enemies
 }
Comment
Add comment · Show 3 · 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 PlatPlayz · Jan 24, 2018 at 06:12 PM 0
Share

How can I make the void DestroyEnemy() if I have OnTriggerEnter there?

avatar image bhavinbhai2707 PlatPlayz · Jan 24, 2018 at 07:29 PM 0
Share

what i wanted to say is once the enemy has actually passed the door then by using triggers just set bool ie shouldbeDestroyed as true it means now the enemy can be destroyed. now consider DestroyEnemy as a function that actually contains the code u r using for destroying them for eg:-

 void DestroyEnemy()
 {
      if(shouldbeDestroyed)
       Gameobject.Destroy(enemy);
 }
 
 //and in case of triggers u can do is
 private void OnTriggerEnter(Collider thecollider)
 {
      if(thecollider.tag == "Enemy")
         {
              DestroyEnemy();
 
 or,
             if(shouldbeDestroyed)
       Gameobject.Destroy(enemy);
         }
 }

avatar image PlatPlayz bhavinbhai2707 · Jan 25, 2018 at 06:44 PM 0
Share

Awesome! With a little bit of tweaking I got this to work! Thank you!

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

85 People are following this question.

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

Related Questions

collision with wall so player dies 1 Answer

Destroy Terrain trees and their colliders. 0 Answers

(in the end of the code...) when i try to run the program that tells me that the object is destoryed and i cant access it someone help? 1 Answer

Destructible walls, or objects (etc...) 3 Answers

*URGENT* Really Basic Script 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