/** * Controller explicitly orders updates: All models then all views. * Was updating on each prefab's component script. Also tried fixed update. * It turns out the order of updates is arbitrary so one view can update before the model and another afterward. * http://answers.unity3d.com/questions/46107/in-what-order-are-all-the-update-functions-called.html * Test case: 2015-11-01 Expect camera smoothly follows player and each keyboard input is processed exactly once. Got player position jitters or keyboard input not processed every time or processed twice. */ public void Update() { UpdateInput(model.steering); model.Update(Time.deltaTime); playerRank = model.playerRank; playerSpeed = SpeedModel.player.speed; SetCompetitorPosition(SpeedModel.competitors); SetRankText(finishText); SetPosition(player.transform, model.steering.x, SpeedModel.player.z); SetPosition(playerCamera.transform, model.steering.cameraX, SpeedModel.player.cameraZ); restart.SetActive(SpeedModel.isRestartEnabled()); if (SpeedModel.isRestart) { SpeedModel.isRestart = false; if (isVerbose) { Debug.Log("RaceModel.Update: Restart"); } Application.LoadLevel(Application.loadedLevel); } }