void colocarObjetos() { Vector3 pos = Camera.main.ViewportToWorldPoint(new Vector3(0.5f, 0.1f, Camera.main.nearClipPlane)); Disparador.SetPosition(new Vector3(pos.x, pos.y, 0)); pos = Camera.main.ViewportToWorldPoint(new Vector3(0.5f, 0f, Camera.main.nearClipPlane)); deadZone.SetPosition(new Vector3(pos.x, pos.y, 0)); deadZone.SetScale(new Vector3(50, 0.2f, 0.2f)); GameObject muroIzquierdo = Instantiate(muro); pos = Camera.main.ViewportToWorldPoint(new Vector3(-0.01f, 0, Camera.main.nearClipPlane)); muroIzquierdo.transform.position = new Vector3(pos.x, pos.y, 0); muroIzquierdo.transform.localScale = new Vector3(-0.1f, 50, 3); GameObject muroDerecho = Instantiate(muro); pos = Camera.main.ViewportToWorldPoint(new Vector3(1.01f, 0, Camera.main.nearClipPlane)); muroDerecho.transform.position = new Vector3(pos.x, pos.y, 0); muroDerecho.transform.localScale = new Vector3(-0.1f, 50, 3); GameObject muroArriba = Instantiate(muro); pos = Camera.main.ViewportToWorldPoint(new Vector3(0.5f, 1, Camera.main.nearClipPlane)); muroArriba.transform.position = new Vector3(pos.x, pos.y, 0); muroArriba.transform.localScale = new Vector3(50, 2f, 3); }
void colocarObjetos() { //Sprite Vector3 pos = Camera.main.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, Camera.main.nearClipPlane)); spriteField.transform.position = new Vector3(pos.x, pos.y, 0); backGround.transform.position = spriteField.transform.position; //Gamefield Renderer rend = spriteField.GetComponent <Renderer>(); //Cogemos bounds del sprite gameField.transform.position = new Vector3(rend.bounds.min.x, rend.bounds.max.y, 0); //Esquina sup izq //Deadzone deadZone.SetPosition(new Vector3(rend.bounds.center.x, rend.bounds.min.y, 0)); deadZone.SetScale(new Vector3(50, 0.2f, 0.2f)); //M-Izq muroIzquierdo.transform.position = new Vector3(rend.bounds.min.x, rend.bounds.center.y, 0); muroIzquierdo.transform.localScale = new Vector3(0.1f, 50, 10); //M-dch muroDerecho.transform.position = new Vector3(rend.bounds.max.x, rend.bounds.center.y, 0); muroDerecho.transform.localScale = new Vector3(0.1f, 50, 10); //M-top muroArriba.transform.position = new Vector3(rend.bounds.center.x, rend.bounds.max.y, 0); muroArriba.transform.localScale = new Vector3(50, 0.1f, 10); //Disparador if (Disparador != null) { Disparador.SetPosition(new Vector3(Disparador.transform.position.x, rend.bounds.min.y + 0.5f, 0)); } }