void playerStartPosition() { // Les joueurs choissisent leurs positions if (Input.GetMouseButtonDown(0) && !launch) { //Debug.Log("TOUCH"); Vector3 pos = Input.mousePosition; //screenPos to worldPos of mousePos pos.z = -Camera.main.transform.position.z; //Pos of player in 2D Vector3 playerPosInWorld = Camera.main.ScreenToWorldPoint(pos); //check vertical if (playerPosInWorld.y > 3.9f) { playerPosInWorld.y = 3.9f; } else if (playerPosInWorld.y < -3.9f) { playerPosInWorld.y = -3.9f; } if ((Input.mousePosition.x > (float)Screen.width / 2)) { //check horizontal if (playerPosInWorld.x > 6.9f) { playerPosInWorld.x = 6.9f; } else if (playerPosInWorld.x < 1.1f) { playerPosInWorld.x = 1.1f; } /************************/ if (Player1 == null) { Player1 = (GameObject)Instantiate(PlayerPrefab, playerPosInWorld, new Quaternion()); Player1.name = "Player1"; scriptP1 = Player1.GetComponent<Player>(); scriptP1.setID(1); scriptP1.ChangeAnimal(false); } else { Player1.transform.position = playerPosInWorld; } } else { //check horizontal if (playerPosInWorld.x < -6.9f) { playerPosInWorld.x = -6.9f; } else if (playerPosInWorld.x > -1.1f) { playerPosInWorld.x = -1.1f; } /****************/ if (Player2 == null) { Player2 = (GameObject)Instantiate(PlayerPrefab, playerPosInWorld, new Quaternion()); Player2.name = "Player2"; scriptP2 = Player2.GetComponent<Player>(); scriptP2.setID(2); scriptP2.ChangeAnimal(true); } else { Player2.transform.position = playerPosInWorld; } } } }