Search Unity

Rhythm game particles not working - not appearing on note hit..

Discussion in 'Editor & General Support' started by Russellcart, Jan 6, 2019.

  1. Russellcart

    Russellcart

    Joined:
    Dec 22, 2018
    Posts:
    2
    Code (CSharp):
    1. If (Input.touchCount > 0 && Input.GetTouch(1).phase == TouchPhase.Began)
    2.          {
    3.              touchPosWorld = Camera.main.ScreenToWorldPoint(Input.GetTouch(1).position);
    4.              Vector2 touchPosWorld2D = new Vector2(touchPosWorld.x, touchPosWorld.y);
    5.              RaycastHit2D hitInformation = Physics2D.Raycast(touchPosWorld2D, Camera.main.transform.forward);
    6.              if (hitInformation.collider.tag != "Button")
    7.              {
    8.                  GameObject touchedObject1 = hitInformation.transform.gameObject;
    9.                  touchedObject1.GetComponent<SpriteRenderer>().sprite = blank;
    10.                  Instantiate(partRed, touchedObject1.transform.position, Quaternion.identity);
    11.                  partRed.Play();
    12.              }
    13.              }
    The above is a snippet of the code I am using. The game object spawns and falls and I want to be able to, when its touched; the sprite go blank and the particle be shown at its location. The sprite changes to blank but the partials won't appear...

    Code (CSharp):
    1. public Parts partsScript;
    2. public GameObject partsObject;
    3. public ParticleSystem partRed;
    4. public ParticleSystem partBlue;
    5. public ParticleSystem partGreen;
    6. public ParticleSystem partYellow;
    7. private ParticleSystem usingThis;
    8. public Sprite blank;
    9. private void Start()
    10. {
    11.      partsObject = GameObject.FindWithTag("Part");
    12.      partsScript = partsObject.GetComponent<Parts>();
    13.      partRed = partsScript.partRed;
    14.      partBlue = partsScript.partBlue;
    15.      partGreen = partsScript.partGreen;
    16.      partYellow = partsScript.partYellow;
    17.      blank = partsScript.blankArrow;
    18. }
    This is the code that is calling the particle systems from another game object and script.

    I am not sure why they are not appearing.

    Thanks for your help in advanced.


    Add comment