• 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 /
This question was closed Mar 26, 2015 at 10:15 AM by Digital-Phantom for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Digital-Phantom · Mar 26, 2015 at 10:08 AM · instantiatecolliderdestroyontriggerenterif statement

Only 1 of 3 conditions being executed in IF statement?(Solved)

This one got me confused. Why is only the 3rd part of the IF statement being executed ?

 void OnTriggerEnter (Collider other) 
     {    
         if (other.tag == "Shot")
         {
             Destroy(other.gameObject);
             Instantiate(invaderExplosion, transform.position, transform.rotation);
             Destroy(gameObject);
         }
 
 

It obviously recognises the projectile(Shot) otherwise the trigger wouldn't destroy the object as in part 3 of the IF statement. So why then does it not destroy the 'Shot' or play/instantiate my effect.

???

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

  • Sort: 
avatar image
0
Best Answer

Answer by Digital-Phantom · Mar 26, 2015 at 10:14 AM

OK that was weird. Closing and reopening unity(5) solved the issue and all works fine now !

???? go figure !

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

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

20 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

Related Questions

OnTriggerEnter() not working 1 Answer

How do you disable your own Collider? Bugfix 1 Answer

How to destroy an instantiated prefab object and keep instantiating it 1 Answer

OnTriggerEnter - check if collider is child 1 Answer

If statement not working inside switch statement 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges