// Update is called once per frame void Update() { //Reset the level if (Input.GetKey("r")) { Application.LoadLevel(0); } //Get a character if (Input.GetKey("1")) { currentCharacter = 0; } if (Input.GetKey("2")) { currentCharacter = 1; } if (Input.GetKey("3")) { currentCharacter = 2; } //Move if (Input.GetKey("right")) { characters[currentCharacter].transform.Translate(Vector3.right * speed * Time.deltaTime); } if (Input.GetKey("left")) { characters[currentCharacter].transform.Translate(Vector3.left * speed * Time.deltaTime); } if (Input.GetKeyDown("space")) { characters[currentCharacter].transform.Translate(Vector3.up * height * Time.deltaTime); } //Center the camera cam.centerCamera(characters[currentCharacter].transform.position.x, characters[currentCharacter].transform.position.y); //Avoid rotation of the current character characters[currentCharacter].transform.rotation = new Quaternion(characters[currentCharacter].transform.rotation.x, characters[currentCharacter].transform.rotation.y, 0f, 0f); }
// Update is called once per frame void Update() { //Reset the level if (Input.GetKey("r")) { SceneManager.LoadScene(currentLevel); } //Get a character if (Input.GetKey("1")) { currentCharacter = 0; } if (Input.GetKey("2")) { currentCharacter = 1; } if (Input.GetKey("3")) { currentCharacter = 2; } //Move if (Input.GetKey("right")) { characters[currentCharacter].transform.Translate(Vector3.right * speed * Time.deltaTime); } if (Input.GetKey("left")) { characters [currentCharacter].transform.Translate(Vector3.left * speed * Time.deltaTime); } if (characters[currentCharacter].canJump && Input.GetKeyDown("space")) { characters[currentCharacter].canJump = false; characters[currentCharacter].transform.Translate(Vector3.up * height * Time.deltaTime); } //Center the camera cam.centerCamera(characters[currentCharacter].transform.position.x, characters[currentCharacter].transform.position.y); //Change character speed & jump depending on the current one if (characters[currentCharacter].transform.name == "thomas") { speed = 0.3f; height = 40f; } else if (characters[currentCharacter].transform.name == "claire") { speed = 0.2f; height = 20f; } else if (characters[currentCharacter].transform.name == "john") { speed = 0.4f; height = 60f; } //Debug if (Input.GetKey("d")) { thomas_exit = true; claire_exit = true; john_exit = true; } }