private void movimientoP2() { if ((selector) && (!tRobo) && !equipo && MngScenes.multijugador) { if (!balon.balonFuera) { if (Input.GetAxisRaw("VerticalP2") > 0) { transform.position += Vector3.up * Time.deltaTime * vel; } if (Input.GetAxisRaw("VerticalP2") < 0) { transform.position += Vector3.down * Time.deltaTime * vel; } if (Input.GetAxisRaw("HorizontalP2") > 0) { transform.position += new Vector3(1, 0) * Time.deltaTime * vel; } if (Input.GetAxisRaw("HorizontalP2") < 0) { transform.position -= new Vector3(1, 0) * Time.deltaTime * vel; } if (Input.GetButtonDown("FaltaP2")) { Vector3 distanciaBalon = balon.transform.position - transform.position; hacerFalta(distanciaBalon.normalized); } } if (Input.GetButtonDown("GolpeoP2") && balonPies && !balonGolpeado) { if (equipo) { balon.ultimoTocado = true; } if (!equipo) { balon.ultimoTocado = false; } balonPies = false; balonGolpeado = true; balon.interceptado = false; balon.tiempo = true; balon.fuerzaL = fuerzaGolpeo; balon.direccion = new Vector2(Input.GetAxisRaw("HorizontalP2"), Input.GetAxisRaw("VerticalP2")); balon.golpeoV2b(); StartCoroutine(setBalonGolpeadoFalse()); StartCoroutine(balon.setBalonTiempoFalse()); } } }
private void movimiento() { Vector3 zonaBalon = posicion.transform.position - balon.transform.position; Vector3 zona = posicion.transform.position - transform.position; Vector3 balonDist = balon.transform.position - transform.position; if (zonaBalon.magnitude < 10f) { transform.position += balonDist.normalized * Time.deltaTime * vel; } else if ((zona.magnitude > 2f) && !balonPies) { transform.position += zona.normalized * Time.deltaTime * vel; } if ((Input.GetButton("Golpeo") && balonPies && !balonGolpeado)) { if (equipo) { balon.ultimoTocado = true; } if (!equipo) { balon.ultimoTocado = false; } balonPies = false; balonGolpeado = true; balon.interceptado = false; balon.tiempo = true; balon.fuerzaL = fuerzaGolpeo; esPortero = false; balon.direccion = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical")); balon.golpeoV2b(); StartCoroutine(setBalonGolpeadoFalse()); StartCoroutine(balon.setBalonTiempoFalse()); } }