Search Unity

my particles won't hit my object

Discussion in 'Scripting' started by brunoenvia, Dec 5, 2019.

  1. brunoenvia

    brunoenvia

    Joined:
    Aug 5, 2019
    Posts:
    52
    my particles aren't debugging or hitting my game object for some reason, i literally have the particles right in front of my game object and i'm pretty sure they are hitting, what could be the issue?

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.SceneManagement;
    5. using UnityEngine.UI;
    6.  
    7. public class PlayerDeath : MonoBehaviour
    8. {
    9.     GetAudioSource audioSFX;
    10.     SceneLoader sceneLoader;  
    11.     [SerializeField] GameObject ball;
    12.     [SerializeField] ParticleSystem deathVFX;    
    13.     [SerializeField] Image loseScreen;
    14.     [SerializeField] Transform playerUI;
    15.     [SerializeField] float delayToShowScreen = 0.5f;
    16.     [SerializeField] GameObject laserParticles;
    17.  
    18.     private void Awake()
    19.     {
    20.            
    21.     }
    22.  
    23.     // Start is called before the first frame update
    24.     void Start()
    25.     {
    26.         audioSFX = FindObjectOfType<GetAudioSource>(); // find this object and reference it whenever the variable is used.
    27.         sceneLoader = FindObjectOfType<SceneLoader>();      
    28.     }
    29.  
    30.     // Update is called once per frame
    31.     void Update()
    32.     {
    33.        
    34.     }
    35.  
    36.      public void OnTriggerEnter(Collider other)
    37.     {
    38.         if (other.gameObject.tag == "DeathTrigger")
    39.         {
    40.             PlayerDying();          
    41.         }
    42.     }
    43.  
    44.     private void OnParticleCollision(GameObject laserParticles)
    45.     {
    46.             Debug.Log(ball);
    47.             PlayerDying();      
    48.     }
    49.  
    50.     public void PlayerDying()
    51.     {
    52.         Debug.Log("laser");
    53.         deathVFX.transform.parent = null; // deathVFX loses it's child relationship with player parent
    54.         deathVFX.Play();
    55.         audioSFX.audioSource.PlayOneShot(audioSFX.deathSFX, 1.5f);       // plays audioSFX
    56.         Destroy(ball);
    57.         Instantiate(loseScreen, playerUI); // instantiates loseScreen as a child of UI game object
    58.     }
    59. }
    60.  
     
  2. brunoenvia

    brunoenvia

    Joined:
    Aug 5, 2019
    Posts:
    52
    please help
     
  3. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    2,117
  4. brunoenvia

    brunoenvia

    Joined:
    Aug 5, 2019
    Posts:
    52
  5. brunoenvia

    brunoenvia

    Joined:
    Aug 5, 2019
    Posts:
    52
    this will only kill me if i put world collision, but the particles will fly randomly around
     
unityunity