Testing the explosion

If you don't want to wait to implement the bullet script to test this function, you can add in the FixedUpdate() so that every time the player presses the key T, the Hit() function is called. Thus, by following a similar process to shooting bullets, we can add the following lines to the function:

        //DEBUG CODE: simulates the Hit() function when the player presses the T key 
        if (Input.GetKeyDown(KeyCode.T)) { 
            Hit(transform.position); 
        } 

And this is how it looks in the game:

The background you see in the image is a demo image of the package. As a pro tip, you can use the demo image as an example image of the level you are going to build. If you place it underneath, you can have a good sense of whether the explosion is working in the future environment or not and adjust it without waiting for the environment to be built. In our case, we might want to scale down the explosion a bit, and maybe save this scaled down into the prefab. Of course, if you like big explosions, you can leave it as it was before. Also, feel free to change the color if you want. 

However, remember to remove these lines (the debug code) once you have finished testing it. Alternatively, you can also comment out the code or surround the debug code with a debugEnabled if statement. However, if the testing code is temporary, erasing it will lead to fewer troubles later on.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset