Search code examples
c#unity-game-engineparticle-system

Made a rain particle effect as a child to main camera which moves upwards but the rain effect is not perfect since its moving north


i made a rain particle system in unity 2d and attached it as a child to main camera so it can move along with the camera towards north. but the rain effect is not perfect as some of the particles are wobbling upward. i have attached a script to the camera which is given below. is there any other way to resolve this issue.

public float  translation ;
public float highspeed;//highest speed of the camera
public float incfactor;//increasing ,multiplying number
float timer=0f ;
 public bool ismoving = false;


Rigidbody2D dia;

void Start()
{

    dia = GetComponent<Rigidbody2D> ();
}


void  Update()
{

    if (Input.GetMouseButtonDown(0)) {
        RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
        if(hit.collider != null) {

            if (hit.collider.tag =="dialogue") {
                FindObjectOfType<audioManager> ().Play ("levelbeginclick");
                Destroy (hit.collider.gameObject);
                ismoving = true;
            }
            }
        }

    if (ismoving == true) {
        Updatemove ();
    }
    }





 public void Updatemove ()
{

    timer += Time.deltaTime;



    if (timer > 1f&& translation<highspeed) { 
            timer = 0; // reset timer
        translation +=incfactor ; 
        }

    transform.Translate (0, translation*Time.deltaTime, 0);




}

public void stopmoving()
{
    ismoving = false;
}

}


Solution

  • So changing the Simulation Space to World as @ARutherford said should do the trick Particle system on Inspector Tab