- Learned how to spawn or shoot projectiles after a key is pressed.
- Learned how colliders work in Unity.
- Learned how to spawn objects randomly on any given location range.
- Learnt how to use the
Instantiatefunction. Implemented in SpawnManager - Learnt how to keep the player in bounds using
ifstatements. - Learnt how to use
InvokeRepeating. InvokeRepeatingcan be used to invoke a function repeatedly with a given time interval. Implemeted in SpawnManager- Also learned about how we can use
Random.Range. But we have to be careful while using this because we cannot use it in an initialization of a global variable, you have to use locally inside a function. For some reason this happens only in a class derived byMonoBehaviourclass.
- Solution: Dogs were spawning on the top because the dog game object was added in the place of ball.
- Solution: Click on
Playerand change the game object to dog in the inspector.
- Solution: The collider for the dog is too big, we have to adjust it properly!
- Soltion: In DestroyOutOfBoundsX.cs we have change the variables to
leftLimit = -45&bottomLimit = -5and also change the if conditions toif (transform.position.x < leftLimit)&else if (transform.position.y < bottomLimit)
- Solution: We have to change a few things in the SpawnManagerX.cs
- Initialise a new variable inside
SpawnRandomBall,int randomIndex = Random.Range(0, ballPrefabs.Length);and add that in theInstantiate
- Solution: To change the spawn interval in SpawnManagerX.cs we have just add anew line before we call
InvokeRepeating. We should add this linefloat spawnInterval = Random.Range(1.0f, 2.5f);.
- Solution: We should add a cooldown as given in the PlayerControllerX.cs
Thank you for reading this far!