Even the simplest unity project can be intimidating to a beginner. Let’s take a look at transitioning between 2 scenes in this article.
The outputs I wanted and my goals were to have more than one scene, and via an input action zoom and change to the other scenes. After accessing the second scene, there should be interactable game objects with pop ups when clicked on.
My OCD for neatness kicks in here, I like having everything related to each other in their seperate folders.
This is how I ordered it:
These will be the parent Folders to keep the Hierarchy view neat and tidy
Rename each game object to:
Move the 2D background png into the bg folder. I have 2 different backgrounds to choose from so that I can swap between them. If I wanted a sunset background or a day desert scene then I can just enable and disable the image game object to whichever one I want.
Move all 3D game objects into the terrain folder. This would be anything relating to the scenery
Move the characters into the characters folder
Move the particle prefabs into the Particle system folder
Now that my OCD is taken care of I feel i need some ambient audio in my demo
Create a new blank game object and reset the values as mentioned above
Rename the game object to AudioSource
On this game object click on Add Component
Type out Audio Source and click add
I want my SFX to loop as the audio is ambient
Tick the loop option and make sure Play on Awake is also ticked (but this should be set as default)
Let’s decide now what game object in the “outdoor scene” is going to be our trigger to transition into the “indoor scene”. I have chosen my zombie character to be the one to be clicked on.
Our script will be coded to find a game object tagged as “Clickable” to know that this is the input object.
I need to add the zombie character’s tag in the following manner:
* Click on your character
* In the inspector, click on the drop down arrow by Tag
* Click on Add Tag
* Click on the plus sign
* Type in the name “Clickable”
* Click on save
![Add a new Tag](/images/scenetransition/9.addtag.png)
* Go back to your character game object
* Click on the drop down next to the heading tag
* Select the option that says “Clickable”
You have now retagged your Game Object. It is very important to note that in the code when you specify which object the ray collides with, that the spelling has to be identical to what you have tagged your object to, so look for spelling mistakes, lower cases , upper cases etc.
There are a few actions we can do before any scripting is needed, for example,
* I want my characters to be animated,
* I need to create a Canvas for my UI interaction,
* and setup my particle system (fire).
Let’s get started with animating our characters.
The designer of the characters I am using gave some awesome animations to go with the assets. They are not attached by default and I will need to set them up.
The idle animation is now all set, click on play and give it a test
I feel my zombie’s idle is too slow, so I want to speed it up abit
Let’s play it again,
Perfect, let’s move on!
You will do the same to setup your other characters with animations too, it’s a rinse and repeat method!
This package has several animations to choose from, so add a few more characters and have fun with these animations
The particle package I downloaded from the asset store has preset prefabs.
That’s it for particle system! All the work was done for us with these prefabs
Thank you Mr Fire particle system effects creator!!
I am using the canvas system for my popup bubble and for the text that is being displayed above my Zombie.
Right click in the hierarchy area
Click on UI
Click on Image
This will create a Canvas that is displayed over my 3D World that has a new 2D sprite image as a child
Click on the new image game object under canvas
Rename it to something that makes sense to you, mine is called img_speechBubble
Drag your speech bubble 2D sprite into the source image area, if it doesn’t want to drop into the image area double check that you have updated the sprite texture type as previously mentioned to Sprite (2D and UI)
Lets now add the text to the speech bubble
Remember the audio source game object we created earlier ? This is where we will now link our ambient desert sfx that will loop