// Runs even if inactive // Initializing variables, setting references privatevoidAwake() { Debug.Log("Awake: " + playerIndex); }
// Start is called before the first frame update // Runs only if active // Gameplay logic, dependent object initialization privatevoidStart() { Debug.Log("Start: " + playerIndex);
if (playerIndex == 0) { this.transform.position = new Vector3(-5.0f, 0.0f, 0.0f); } elseif (playerIndex == 1) { this.transform.position = new Vector3(5.0f, 0.0f, 0.0f); } }
// Update is called once per frame // Handling input, animations, UI updates, non-physics movement // Faster (reacts instantly, runs as often as possible) privatevoidUpdate() { transform.position += new Vector3(moveInput.x, 0, moveInput.y) * Time.deltaTime * 5f; }
// Physics calculations, applying forces (Rigidbody.AddForce()), and physics-based movement // Slower(runs less frequently, only at fixed physics steps) privatevoidFixedUpdate() { } }