Search Unity

The imported package didn't work correctly

Discussion in 'Package Manager' started by IqraImtiaz, Feb 13, 2021.

  1. IqraImtiaz

    IqraImtiaz

    Joined:
    Feb 3, 2021
    Posts:
    16
    Hello, I am building a game whose goal is to destroy stones randomly generated from bottom to top of the screen and when click on stone then they destroy. It works fine till here. But when I added explosion, the objective is to when clicking the stone it shows some explosion and then destroys. For explosion, I imported a package named SmallExplosion. After importing this, for destroying stones I need to clicking continuously on-screen and an explosion appears somewhere else on the screen and some times not appear.
    Most important my touch screen didn't work in destroying stones(before it works correctly) after importing the package. Someone have an idea why this explosion didn't work correctly. Instead of a single click for destroying, I need to click many times and even this doesn't sometimes. How this could be fixed??

    P.S: The stones I made is through prefab (3 prefabs) and the instantiation of explosion prefab is added with each prefab. Here is the stone and explosion destruction code:

    Code (CSharp):
    1. public class Stone : MonoBehaviour
    2. {
    3.     private const float yDie = -30f;
    4.     public GameObject explosion;
    5.  
    6.     void Start()
    7.     {
    8.        
    9.     }
    10.  
    11.     // Update is called once per frame
    12.     void Update()
    13.     {
    14.         if(transform.position.y<yDie)      //this is for destry stones once they go down
    15.         {
    16.             Destroy(gameObject);
    17.         }
    18.        
    19.     }
    20.  
    21.     private void OnMouseDown()      //this is for destory stones and explosion instantiation and destruction
    22.     {
    23.         Destroy(Instantiate(explosion, transform.transform.position, Quaternion.identity),2.0f);
    24.         Destroy(gameObject);
    25.     }
    26. }
    The imported package is here:
    I am following from this tutorial video:
     

    Attached Files: