// Update is called once per frame void Update() { CheckForLevelEditing(); int currentLayerIndex = globalGameData.GetCurrentLayerIndex(); if (currentLayerIndex != previousLayerIndex) { //Update this player layer GetComponent <PlayerDeath>().layer = globalGameData.allLayers[currentLayerIndex]; shield.SetActive(currentLayerIndex != 0); shieldCircle.SetActive(currentLayerIndex != 0); if (previousLayerIndex < currentLayerIndex) { if (currentLayerIndex == 1) { SetPlayerColor(new Color(0, 1, 1)); dummyController0.Pop(transform.position); } else if (currentLayerIndex == 2) { SetPlayerColor(new Color(1, 1, 0)); dummyController1.Pop(transform.position); } } else { if (currentLayerIndex == 0) { SetPlayerColor(new Color(1, 1, 1)); transform.position = dummyController0.transform.position; dummyController0.Depop(); } else if (currentLayerIndex == 1) { SetPlayerColor(new Color(0, 1, 1)); transform.position = dummyController1.transform.position; dummyController1.Depop(); } } previousLayerIndex = currentLayerIndex; } float horizontal = globalGameData.GetPlayerHorizontalMove(); float vertical = globalGameData.GetPlayerVerticalMove(); if (horizontal > 0) { transform.Translate(Vector3.right * Time.deltaTime * Speed); } else if (horizontal < 0) { transform.Translate(Vector3.left * Time.deltaTime * Speed); } if (vertical > 0) { transform.Translate(new Vector3(0, 1, 0) * Time.deltaTime * Speed); } else if (vertical < 0) { transform.Translate(new Vector3(0, -1, 0) * Time.deltaTime * Speed); } if (horizontal == 0 && vertical == 0) { moveAudioSource.Stop(); } else { if (!moveAudioSource.isPlaying) { moveAudioSource.Play(); } } }