theheartofaprogrammingdevil
theheartofaprogrammingdevil
May your Heart be your Guiding Key
21 posts
Here we play games, write code, and try to spread knowledge throughout the world.
Don't wanna be here? Send us removal request.
Photo
Tumblr media Tumblr media Tumblr media Tumblr media Tumblr media
A friend of mine used the term “smoldegard” when we were talking about 3h and this is all that I’ve been thinking about for the past 2 days
4K notes · View notes
Text
Post 8 - The Path of a Programmer
Hello everyone and welcome to the final blog post of this semester. It is a little late due to finals, but better late than never. This post will be a wrap up post and offer a bit of reflection on what we have done with Unity up until this point, so I hope you enjoy.
First, I want to say that making a blog is not an easy thing. It takes a lot of time and dedication to make a blog, let alone a good one. I do not think that I will be continuing this blog after this, mainly because working with Unity to make content on this blog has been a very rough time. Personally, I think I will do more stuff with Unity on my own time, but not on this blog. I will leave the posts up as they might be helpful to someone out there, especially if they want something fairly obscure.
On a side note, I would like to thank Ryan and Liam for giving comments throughout the semester, even though that was part of the assignment. Your guy’s comments really helped in expanding what I put out on this blog.
Anyway, the second I want to say is that Unity is a complicated system that goes under the guise of something simple and easy to understand. It offers a lot of variety in terms of making games, especially with the massive asset store at your disposal. However, Unity can be unforgiving. There is always some update available for Unity, which can be good and bad. The good is that it might fix a previous issue, the bad is that it might introduce a whole lot of new issues. Like with the 2D game kit. After I updated it to the latest version of Unity, I had 84 different errors in the game. Not to mention the inherit error of not being to transition between scenes. Another thing that makes Unity hard to use is trying to figure out where things are getting saved. If you make a new project, it does not get saved to your computer right away. It only really saves it after you try and exit Unity. This can be annoying as it makes it hard to find what you were working on if Unity crashes or something happens to your computer. One last thing about Unity is that it requires a lot, and I mean a lot, of tutorials and research before you can get into making anything significant. I guess it is supposed to be like that so that you challenge yourself to put in the time and dedication to making something.
For your first game and maybe a second or third game, you will not be making anything spectacular. In fact, it may be so lackluster that it makes you wonder how so many companies can use Unity to make games. This is simply because you are an individual starting out and they are a team with experience. So, don’t get discouraged if you make something with errors and weird shapes. It is all part of the learning process as with anything.
Through all the bumps and curves of this semester, we made it to the end. There were some ups and downs, but that is the life us programmers choose to live. I hope at the very least that this blog shows that if you keep working at things, they will get better. Also, if things are going beyond your control, it may be wise to stop, reflect, and change course. In the end, it is up to you to find the path you walk. So, wake up, get up, and get out there. Find your path and walk it with pride. With that in mind, I am the Programming Devil, and May your Heart be your Guiding Key.
0 notes
Note
In regards to your last post a 2d World, have you figured out why you got that error and been able to complete the kit's tutorial? - Liam
No I was unable to figure what caused the error with the Game Kit. In fact after letting it sit for a while, more errors appeared. Far too many for me to handle.
0 notes
Text
Post 7 - Road Bumps and the Beginning of the End
Hello Everyone and welcome back to the blog. Today we will be checking out more of the 2D game that we were working on last time, so open Unity and let us start the game. Or so I had thought. I was experiencing issues with the project not running and I decided to let Unity update itself. Big Mistake. After updating Unity and waiting 20 or so minutes for it to open the 2D game, it came with 87 errors of things that had either changed or needed to be changed. 87 is a lot to deal with, so the 2D game is getting scrapped. Sorry for everyone looking forward to it. Instead, let us look at an aspect of Unity that we have not explored yet. That being the Unity Asset Store.
https://assetstore.unity.com/
Here we can find different Assets and Projects to work on to get ourselves more familiar with Unity.
Tumblr media
Once you’re on the site you can see that there is a lot of stuff to look through. For our purposes we will be looking at the free packages, but feel free to purchase some if you’d like.
Anyway, we are going to look at the Sunny Land package and see what we can do with it. Hopefully this one works better than the 2D Game Kit.
Tumblr media
Go on and click add to my assets and we will get started. Remember to log in first so it can be added. After it has been added, the button will change to open in Unity, so go on and click on it.
Tumblr media
Once Unity starts up it will ask you if want to create an empty project. Click that and go to the folder that you want it to be saved in. There is not a tutorial for Sunny Land so we will be making one from scratch. First let’s create the background.
First go to the Project window and look in the artwork folder, select the back Prefab and move it into the Scene View, like so.
Tumblr media
Next let us add some ground. Go to the Project window and drag the long platform into the scene view. It’ll be small so make sure to resize it.
Tumblr media
Now we have our scene. I also added a sprite of the character, so we can use them. As I said before, this package has no tutorial, but it also has no scripts, so the game does not actually do anything. Let’s change that.
Go to the character and click on add component. The scroll to the bottom and we will create a new script. The script will be called PlayerController. Open it with Visual Studio and input this code into the script.
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour {
public float speed;            
//Floating point variable to store the player's movement speed.
     private Rigidbody2D rb2d;      
//Store a reference to the Rigidbody2D component required to use 2D Physics.
     // Use this for initialization
   void Start()
   {
       //Get and store a reference to the Rigidbody2D component so that we can access it.
       rb2d = GetComponent<Rigidbody2D> ();
   }
     //FixedUpdate is called at a fixed interval and is independent of frame rate. Put physics code here.
   void FixedUpdate()
   {
       //Store the current horizontal input in the float moveHorizontal.
       float moveHorizontal = Input.GetAxis ("Horizontal");
         //Store the current vertical input in the float moveVertical.
       float moveVertical = Input.GetAxis ("Vertical");
         //Use the two store floats to create a new Vector2 variable movement.
       Vector2 movement = new Vector2 (moveHorizontal, moveVertical);
         //Call the AddForce function of our Rigidbody2D rb2d supplying movement multiplied by speed to move our player.
       rb2d.AddForce (movement * speed);
   }
}
Make sure to save the script then go back to Unity. Before we can see the effects of this script, we need to add the RigidBody2D component to the character. Adding the RigidBody2D component to the platforms is recommended as well. Now enter Play Mode and you will have control over the character. When you use the arrow keys, the character will continuously slide in the direction of input, which is fine for now.
Tumblr media
This post could go on for much longer with all the different assets and possibilities that are in this package. There are houses, trees, levers, collectible items, and so much more to see and do. However, I think I will end it here. I hope that this post has given you all at least a little taste of what Unity’s Asset store has to offer. There are so many different packages to choose from in the store, so take some time and look through them. The next post will be the last of this semesters posts and will be a wrap up of everything that we have gone so far. I hope you look forward to it. Until then, I am the Programming Devil and May Your Heart Be Your Guiding Key.
0 notes
Note
I am enjoying your blog, especially post 6 because its working with a 2D game! Also, are you able to create animations in Unity? If so, do you recommend it or do you find other tools, like Blender, are better? Thank you in advance! (Ryan)
Unity has its own way animation system that people can use to create animations for GameObjects. Animations can also be imported from external sources. Check out these links in Unity’s documentation on the different aspects of animation and exporting from external animation apps.
https://docs.unity3d.com/Manual/AnimationOverview.html
https://docs.unity3d.com/Manual/AnimationsImport.html
https://docs.unity3d.com/Manual/HOWTO-exportFBX.html
0 notes
Note
I am excited that you are starting to explore 2D in this blog. One question though: if I run into issues with my code, what online resources would you recommend to support debugging efforts? I have relied upon Stack Overflow in the past, but I do not know if there is a better resource for Unity. Thank you. (Ryan)
Hey Ryan. Unity has a community of different resources for people to ask questions, look at current bugs, and more. Also Unity has a ton of Documentation to look through. Take a look here
https://unity3d.com/community
0 notes
Text
Post 6 - A 2D World
Hello everyone and welcome to the 6th post of this blog. Today we will be stepping up into the world and exploring and fully decked out 2D game. As you know, Unity has a ton of built in and pre-built aspects for us to explore and this project is no different. Here we will be looking at the 2D Game Kit, which contains an 2D side scroller adventure game for us to mess with.
Tumblr media
To get started with this Game Kit, it will need to be downloaded. This can take awhile so sit back relax and listen to your favorite songs as it downloads onto your computer. Also, if you just want to see what we will be doing today after finishing the basic tutorial involved with this Game Kit then visit this website to see the steps of making the current scene we have.
https://unity3d.com/learn/tutorials/projects/2d-game-kit/game-kit-introduction
This site will give you all the information you need to know about the level we will be making in the Game kit. I also want to give everyone a warning about this tutorial. In the last section of it, there is a part for transitioning from one scene to another. However, this part of the script to do that gives and index out of bounds error when you try to use it. I tried to look at the script to see what it was doing but trying to open it made the Unity editor go completely crazy. It froze, and I could not even close it. I had to use the Task Manager and shut Unity down completely. As of when I am posting this, the issue has not been resolved. So, for now we will not be exploring that aspect of this Game Kit. Instead, we will be using the teleporting in the same scene aspect as that works fine. Anyway, let us get into it.
I have two main goals for this post. One is I want to add some background music to this level. The other goal is that I want to add some functionality that prevents the player from infinitely falling if they fall off a platform. Let’s start with the music.
Head to the Project window and look in the Assets folder. Then go to Prefabs and then audio.
Tumblr media
Here we will see that the Game Kit has a Background music player. Lucky us. Now drag the music player into the scene. It does not matter where you put it as it is invisible and not interactable. Let us look at what the BackgroundMusicPlayer has for us.
Tumblr media
If we look at the Inspector window for the BackgroundMusicPlayer, we can see that the Game Kit also has some music set up for us to use. Enter Play mode and turn your volume up to hear.
Tumblr media
The Game Kit comes with 3 music tracks that seem to be imported assets. I believe you would have to create the music in another application for it to be used in Unity, so we will leave that be for now. However, it is cool that we can play some music for our game.
Next, I was going to show you a way of preventing the infinite character fall. However, I have run into a little problem. Remember earlier in the post when I said that trying to edit a script made the editor freeze for me? Well it turns out that will happen if you try and create your own script in the Game Kit too. So, big egg on my face. Anyway, I can still show the script would be prevent the infinite fall.
public class FallPrevent : MonoBehaviour
{
     // Attach this script as a component to the character
     private float Xorigin;
     private float Zorigin;
     private float Height;
         private void Awake()
     {
         // Setting Startpoint
         Xorigin = transform.position.x;
         Zorigin = transform.position.z;
         Height = transform.position.y;
         // Asking Height
         if (Height < 0)
         {
             Height += 3;
         }
     }
     void Update ()
     {
         // Character respawns to the starting point when falling.
         if (transform.position.y < 0)
         {
             transform.position = new Vector3(Xorigin, Height, Zorigin);
         }
     }
 }
What this code does is gets the players starting position and transports them back to that position if their y position goes less than zero. I wish I could have added it to the 2D game, but I guess it was not meant to be. Oh well.
Sorry about all the bumps in the road. I guess the developers of Unity have some work to do, but I won’t let that deter me. There is still a lot to do with Unity and we have only scratched the surface. Next week we will continue with this 2D game and see if we can expand the level with a bunch of different GameObjects. Until then, I am the Programming Devil and May Your Heart Be Your Guiding Key.
0 notes
Note
Thank you for responding to my question on accessing other scripts. You copied and pasted the walls and floors for your previous post, what should we do if we wanted to make our own object from scratch how would we get it into Unity?
This is a good question to ask. I recommend checking out this website as it gives information about how to build a basic Unity 3D game from scratch.
https://www.instructables.com/id/How-to-make-a-simple-game-in-Unity-3D/
In summary of what this site says, you would use the built in Unity objects like cubes and use the transform attribute to manipulate the cube to be whatever structure you need it to be. I hope this helps.
0 notes
Note
Thank you for responding to my comment regarding the history of Unity. I understand you can use Unity to develop games for mobile, desktop, VR/AR, and consoles. Can you establish one build that can be deployed to all devices/platforms or do you need to create separate builds for each device? (Ryan)
This is a good question. When you are installing Unity onto computer it comes with a lot of options including the basic editor as well as editor for mobile and other platforms. So, I believe you have to do them separately as Unity has a separate environment for the different platforms.
0 notes
Note
Thank you for addressing the question noted in my last comment! I am enjoying your tutorials a lot and I think you are doing a great job creating step by step directions. In addition to your tutorials, may you please talk about the history of Unity? I understand its first release was in 2005 but I am curious to see how the technology has changed over time. Thank you in advance!
Thank you, Ryan for your question and here are a few notable events throughout the history of Unity.
Unity Technologies was founded on 2 August 2004 by David Helgason (CEO), Nicholas Francis (CCO), and Joachim Ante (CTO) in Copenhagen, Denmark after their first game, GooBall, failed to gain success. The three recognized the value in engine and tools development and set out to create an engine developed in-house that any and all could use for an affordable price. Unity Technologies has received funding from the likes of Sequoia Capital, WestSummit Capital, and iGlobe Partners.
In 2008, with the rise of the iPhone, Unity was one of the first engine developers to begin supporting the platform in full. Unity now supports 27 platforms, including Oculus Rift, Xbox One, PlayStation 4 and Linux.
In 2010, IBM started exploring Unity 3D-based browser plug-ins, as a way to access 3D virtual worlds from within a Web browser.
In April 2012, Unity reportedly had 1 million registered developers, 300,000 of which used Unity on a regular monthly basis.
Facebook integrated a software development kit for games using the Unity game engine in 2013
In April 2015, the number of reported registered developers reached 4.5 million, with 1 million monthly active users. 47% of all mobile game developers use Unity.
By 2016, the company reported more than 5.5 million registered users.
Unity held the Vision Summit 2016 in February 2016, a VR/AR conference, where they announced their VR/AR division, Unity Labs.
On 29 January 2019, Unity Technologies acquired Vivox, a company that develops text chat and 3d positional voice and communication technology for titles such as Fortnite, PlayerUnknown's Battlegrounds, and League of Legends.
I hope this answers your question and I look forward to more questions from you.
0 notes
Text
Post 5 - A Fresh Start
Hello everyone and welcome back to this week’s blog. It seems that I have been babying you in terms of just giving tutorials that you could easily find online and I have to create something new for you all to look at, at least that is what my professor wants. So, forget about what I said in the last post because we are starting over. Well don’t forget everything, remember the concepts from the tutorials and you can always refer to them in the old posts. Anyway, what we will be doing today is going back to the last tutorial on Prefabs and adding some stuff to it to make it go beyond the tutorial. Exciting, right? So, let’s get started, open the Prefab Power tutorial and get to the end of it, then we will continue from there.
Before we do anything in Unity though I will address a question posted last week. The question was can other scripts be accessed by another script or can only one script be called in a scene. The answer is yes, you can call other components in a script you create. If you want more information on this and other info on scripts, you can refer to the Unity documentation here:
        https://docs.unity3d.com/Manual/ControllingGameObjectsComponents.html
Now, back to the games.
Tumblr media
Here we have the completed tutorial on Prefabs. Now let us go about adding some more Game Objects to the Scene.
The first thing we are going to do is add another floor to this scene. To do this go into the Hierarchy Window and open the Environment tab. Here is where all the different environments are stored. Here we are looking for WallsAndFloors.
Tumblr media
In WallsAndFloors, we will see just that. All the walls and floors that are used in this scene. So, to add another floor to this scene, we enter the WallsAndFloors and click on the GameObject floor. This floor in particular is the main floor of the scene.
Tumblr media
As you can see, the tutorial has multiple floors, which have awful names by the way. But, we are not here to change that. Instead, we are here to add a floor. What I did, was copied the original ‘floor’ and pasted it into the WallsAndFloors folder. I then gave set its position to be the following.
           X: 23 Y: 0 Z: 2.5
This positioned the floor right next to the lower right side of the scene. Now let’s get rid of the wall blocking access to our floor. For that I deleted WallStraightTall (6). I also deleted floor (3) as it is blocking the aerial view of our floor. With all that the scene will now look like this.
Tumblr media
If you want to add walls to the floor as well, all you would need to do is follow the same steps as above and change their positions to match what you want it to look like.
Tumblr media
Now that we have walls to keep the player in, let’s give them a challenge. I am going to add another wall and a laser for the player to maneuver through to get to the goal. Make copies of the LaserNode object, the LaserNodePillar, and LaserLine objects to accomplish this. Also make use of the rotation attribute in the Transform component if you want to change the way an object is facing.
Tumblr media
Now that we have the wall and laser up, let us give a way to get past. So, let us add another robotic arm and pushableBox to scene.
Tumblr media
You can set up the box and robotic arm however you like, I set mine to be on the right side with the player. Also, to make this worth anything, we need to change the player’s starting position to before the obstacle. Now that we have set up the obstacle let’s run it and see what we have got.
Side Note: When creating a new interactable GameObject like the PushableBox, RoboticArm, or the SwitchSquare, make sure to give them a unique name as Unity wants these objects to all be unique. It also helps in defines what switches affect which objects.
Tumblr media
It works, just like it should. Now we can finish the level like usual and claim the goal.
I hope that this post was helpful in showing a little bit of what Unity is about and the process of what goes into to building a scene. If you have any questions or suggestions for anything to add to this project, please don’t hesitate to comment. Next post I think I will show you all a 2D game. Until then, I am the Programming Devil and May Your Heart Be Your Guiding Key.
0 notes
Note
This is for post #2: Downloading UNITY. Some of your screenshots, because they are scaled down, cannot be read. Not sure if we need to read them. Seems like you should either make them big enough to read, or leave them out.
Thank you for the feedback. I'll look into it.
0 notes
Note
In creating a unity script can other scripts be accessed by another script or can only one script be called in a scene? - Liam
This is a good question. At the moment, I am not sure. However I will look into it and address it in the next post. Thanks Liam
0 notes
Note
In tutorial 2 how does the robot block you initially? Is there a built in ability that allows it to track or hunt down the player, or does it follow a pre built path we can't see? -Liam
Yes, the picture is a bit misleading. The robot initially is following a pre set path in front of the opening and is moving too quickly for the player to progress through in a meaningful way. That is why we changed it's speed from 10 to 1, so the player has a more realistic chance of getting past the robot.
0 notes
Note
In regards to your first tutorial the RigidBody component adds gravity to an object which makes sense to me on why the first box falls with the platform. The second box does not move horizontally unless if RigidBody is added as a component so I am assuming by gravity you are saying it allows the object to then move in all directions? - Liam
The RigidBody component adds physics to an object. The example I was using at the time was gravity, but the RigidBody gives more than just that. As you can see from the tutorial it also allows objects to be moved. Thank you for the question.
0 notes
Text
Post 4 - Creating an Unity Script
Hello everyone and welcome to this week’s blog. Today I will be giving you some info about creating a script for a game object in Unity. As we know, Unity has a ton of built-in components for us to use. However, these components can be limiting in what they offer. Have no fear, Scripts are here. A script is a component that we create ourselves, and they allow you to trigger game events, modify Component properties over time and respond to user input in any way you like. Cool, huh? Anyway, scripts are made in the programming language C# (c-sharp) in Visual Studio, which came downloaded with the Unity editor. So today, we will be making some basic scripts so that we can familiarize ourselves with this process.
First, let’s start up Unity and create a new project. For this project we will doing a 2D game, and you can name it whatever you like. Then click create project.
Tumblr media
Once you have the project open, add a game object to scene like a square or a diamond. We will get into making a real scene at a later time, but for our purposes we just need a basic game object. Components are only useful when they are attached to game objects, so we will need an object to test our scripts.
Tumblr media
Here is roughly what you will see after adding some stuff to the scene. Now we are going to create a script for this red diamond here. To do this, go to the Project window and click on Create. There a large list will appear, click on the C# Script at the very top on the menu and boom a script is created. Now give the script a name, I will name it MainCharacter, but it is up to you on how you want to name it.
Tumblr media
Now the Script will appear in the Project window. Click on it and you will see what code it has inside of it. A fresh script will have this in it.
Tumblr media
From this point on, we will be getting into some programmer techy lingo so feel free to look up anything that you are confused about or leave a question or comment and I will answer as best I can.
Anyway, as you can see we have a Class that is the name of the Script and it implements the MonoBehaviour class. This class connects the script with the internal workings of Unity. Remember, the class name and file name must be the same to enable the script component to be attached to a GameObject. Next, we have two functions of this class. The Update function is the place to put code that will handle the frame update for the GameObject. This might include movement, triggering actions and responding to user input, basically anything that needs to be handled over time during gameplay. To enable the Update function to do its work, it is often useful to be able to set up variables, read preferences and make connections with other GameObjects before any game action takes place. The Start function will be called by Unity before gameplay begins (ie, before the Update function is called for the first time) and is an ideal place to do any initialization.
Now that we have that out of the way, let’s start editing this script. To do this, double click on the script in the Project View and it will open in Visual Studio.
Tumblr media
Now that we have it open in Visual Studio, we can finally get to work. First let’s do what every programmer’s first program is. Hello World. Type in the following line into the Start() function.
           Debug.Log("Hello World!");
Debug.Log is a simple command that just prints a message to Unity’s console output. Now save the program and go back to the Unity editor. Add the script to your diamond by clicking on it in the Hierarchy window and dragging the script into the Inspector window. Press the play button and you should see the message at the bottom of the main Unity editor window.
Tumblr media
You will see the script appear in the Inspector window like this.
Tumblr media
Congratulations, you are now a programmer. How does it feel? Good right. Now let us do one more thing before the end of this post. Let’s create an input variable. Go back to Visual studio and replace the line we made in the Start() function with this.
           Debug.Log("Hello World! My name is " + myName);
Also add this line to the outside of the Start() function.
           public string myName;
The result should look like this.
Tumblr media
What we have done is created a string variable that will hold a player’s name. When we run this code, the Inspector window will have a spot for input. Let’s try it out. Save the program and go back to the editor.
Tumblr media
Put your name into the My Name attribute here.
Tumblr media
Enter Play Mode. There, you will see the Hello World message.
This is only the surface of what we can do with scripts. Next week, we will go into making more in-depth scripts and I hope you are all looking forward to it. Remember to leave questions or comments if you have them. Until we meet again, I am the Programming Devil and May Your Heart Be Your Guiding Key.
0 notes
Text
Post 3 -Tutorials Part 2
Hello everyone and welcome to this week’s blog post. Today we will be continuing with the basic tutorials of how to use Unity.
Tumblr media
First, we will be looking at Tweaking Components, so go on and start it up.
Once Unity loads up, we will start with learning how to set values to components. Now let us enter Play mode and see what the game level has in store for us.
Tumblr media
As we can see, when our player steps on the red square, an enemy NPC comes rushing out. He is going so fast that our player can’t get through. Let’s do something about that. Exit Play Mode and we’ll take care of the trash.
Tumblr media
Go to the Hierarchy Window and select the Enemy game object. From there Inspector window will open with the Enemy’s info. Here we are looking for it’s speed attribute in the NavMeshAgent component. This component is part of Unity’s built in AI system. When a game object has the NavMeshAgent component attached to it, it will use AI to interact with it’s environment. In the speed attribute set the speed to 1. This will allow us to change how fast the object goes around the environment, isn’t that useful.
Tumblr media
Now let’s go into Play mode and try to get past the enemy now.
Tumblr media
Great. The enemy is so slow we can go right past them without worry. However, now the door to the goal blocked a by a fast closing door, which is not very epic gamer style. Exit Play mode and let’s fix it.
Tumblr media
Go back to the Hierarchy window and select the Automatic Doors Game Object and go to the Inspector window.
Tumblr media
From there, we will be looking for the Time Until Close attribute which is under the Door component. This component is not a built-in component of Unity, it is a script made in code, which is something we will be doing in the next post. For now, set the Time Until Close attribute to 10 and enter Play Mode to see the results.
Tumblr media
There we go. We made it to the goal, which is indeed an Epic Gamer moment.
Tumblr media
With that the Tweaking Components tutorial is done. Next, we will do the final basic tutorial of Prefab Power. The excitement is overwhelming, so let’s jump right in.
A Prefab is a file that contains a Game Object that works in the way it is supposed to. By creating a Prefab, we can take that fully functioning Game Object and make copies of it. Before we get into how to make a Prefab, let’s enter Play Mode and see what we have to work with.
Tumblr media
When we move our character to green triangle, we see the door object open to the goal. However, we cannot get over to the goal. With no ability to jump, we have to figure out a way to get through. Exit Play Mode and let’s do just that.
Tumblr media
This time we will be going to the Project window. The Project window shows all the files that are used in the game, which are called assets, and let me tell you we got some nice assets. Anyway, assets cover things like models, audio, scripts and so on. Here in this window is where we will find the Prefabs. Now select the ramp Prefab.
From the Project window, we can drag a copy of the Prefab into our Scene view or the Hierarchy window. Doing this creates an instance of the Prefab. Now let’s try just that.
Tumblr media
As you can see, by dragging the ramp Prefab into the empty space of the Hierarchy window, it placed it right into the Scene View for us. Now our character can gain the high ground over his former friend. *cough* Star Wars reference. Anyway, let us enter Play Mode and get the high ground.
Tumblr media
We did it, we have the high ground, but another obstacle blocks our way. Looks we need another Prefab to block the laser. Exit Play Mode and let’s get down to business to defeat the Huns. *cough* Mulan reference.
Tumblr media
Go back to the Project window and drag the PushableBox Prefab into the Hierarchy view. You’ll notice that the Prefab is not in the place we need it to be, so let’s fix that. For that we will be adjusting the values in the Transform component of the box. All Game Objects have a Transform component, which holds data about where the object is in the scene, how it is scaled, and how it is rotated.
Tumblr media
In the Inspector window, go to the boxes position attribute and set the X value to -2.
Tumblr media
From there we can see that the box moved to the right a little. Now let’s move it in the Y direction.
Tumblr media Tumblr media
Change the Y value to be 2.5 and watch what happens. Now the box is floating in the air. Creepy right, well there is one more direction for this box to move and that is in the Z direction.
Tumblr media Tumblr media
Now replace the Z value with 10 and the box will be in place to move it move it. *cough* Madagascar reference. Gosh guys I’m sorry about my coughs, must be coming down with something. Anyway, everything is set up, so let’s dive right into Play Mode.
Tumblr media
Alright, we made it to the goal. Epic Gamer Moment achieved.
I hope this post was helpful in teaching about setting values to components and using Prefabs to get things done. Next weeks post is where we will be making some Unity scripts with C# in Visual Studio. I hope your looking forward to it. Until then I am the Programming Devil and May Your Heart Be Your Guiding Key.
0 notes