Unity Lecture #5:
Advanced Code Tips
Copyright 2022 © Extended Reality at Berkeley
Randomization
2
Time
3
Void Update(){ seconds += Time.deltaTime; } |
Enumerations (Enum)
4
enum EnemyState {Run, Walk, Attack}; EnemyState currentState; Void Start(){ currentState = EnemyState.Run; } | isRunning = true; isWalking = false; isAttacking = false; |
Coroutines
5
IEnumerator Attack(){ Do something
Yield return null; Do something else } |
Coroutines (cont)
6
Manager
7
Null Reference Exceptions
8