Ejemplo n.º 1
0
    private void UpdateParallax(object sender, ParaCamArgs e)
    {
        float zfactor = 7f / e.orthoSize;	//kinda arbitrary, but parallax should be less if camera is zoomed out
        Vector3 newPos = transform.position;
        if (moveHorizontally)
        {
            newPos.x += e.dx * horizontalFactor;
        }
        if (moveVertically)
        {
            newPos.y += e.dy * verticalFactor;

        }
        transform.position = newPos;
    }
Ejemplo n.º 2
0
 // Update is called once per frame
 void Update()
 {
     float x = transform.position.x;
     float y = transform.position.y;
     if ((Mathf.Abs(x - mX) > epsilon
      	|| Mathf.Abs(y - mY) > epsilon)
         && ChangeHandler != null)
     {
         ParaCamArgs e = new ParaCamArgs();
         e.dx = x - mX;
         e.dy = y - mY;
         e.orthoSize = camComponent.orthographicSize;
         ChangeHandler(this, e);
     }
     mX = x;
     mY = y;
 }