Home > Mobile >  Particle System not Initializing
Particle System not Initializing

Time:05-06

I am trying to have a particle system instantiated right before my prefabed object is destroyed, and I can't find out what isn't working. I have play-on-awake checked.

    [SerializeField] ParticleSystem destruction;
if (destruction != null)
        {

            Debug.Log("this objects transform: "   this.transform);
            Instantiate(destruction, this.transform);
            
        }

        if (tag != "Wall")
        {
            Destroy(gameObject);
        }

CodePudding user response:

Using

Instantiate(destruction, this.transform.position, this.transform.rotation);

worked.

CodePudding user response:

The usage of Instantiate in Unity, this is a simple example

       //pass in d preset
    public GameObject explosion; // Explosion effect Prefab component  (an explosion animation)

      void OnExplode()
     {
       // Create a Quaternion with a random rotation angle
       // Quaternion.Euler Euler angles
       // Returns a rotation angle that rotates y degrees around the y axis, x degrees around the x axis, and z degrees around the z axis.
     Quaternion randomRotation = Quaternion.Euler(0f, 0f, Random.Range(0f, 360f));

     // Initialize the instance of explosion
     // Parameter 1: is the preset Parameter 2: The coordinates of the instantiated preset Parameter 3: The rotation angle of the instantiated preset
     Instantiate(explosion, transform.position, randomRotation);
    }

Thank you hope it can help you

  • Related