Quantcast
Channel: Answers for "all objects sharing script get destroyed?"
Browsing latest articles
Browse All 9 View Live

Answer by ICHeeryI

Here is code: //Destroy object on click var hit : RaycastHit; var ray = Camera.main.ScreenPointToRay (Input.mousePosition); if ( Physics.Raycast ( ray, hit, 100 )) { if (...

View Article


Answer by robhuhn

I guess because all of them have the tag "resource". You should check if *this* is the clicked object or destroy the object which was hit. (code not tested) if (hit.gameObject.Equals(gameObject)) {...

View Article


Answer by DeveshPandey

Add one more condition like- if (hit.transform.tag == "resource" && hit.gameObject == gameObject) { Destroy ( gameObject ); }

View Article
Browsing latest articles
Browse All 9 View Live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>