![]() ![]() To change the object’s position, you select one in the Hierarchy and navigate to the Transform component in the Inspector. You’ll need to change their positions, so they aren’t overlapping each other. This example gives the capsules the names Char1, Char2, Char3. Do this three times or copy the first object, and you can also give them names if you wish. All you have to do is go to the Hierarchy window, click the Create button, and choose 3D Object -> Capsule shown in Figure 5. The “characters” are the easiest part, so you can start there. ![]() It consists of two major parts – there’s the user interface which displays the statistics given to various scriptable objects and the three capsules representing characters. Now comes the time to create the actual scene this where this game takes place. This example uses green and blue, but they can be any color of your choosing. After this, you should create two more materials and assign their colors. In the above example, the RGB values would be 255, 0, 0. The color is changed either by moving the small circle in the color picker or by directly inputting the RGB values in the lower half of the color picker window. In the Albedo field, there’s a color picker shown in Figure 4 you can click on to open the, well, color picker. To set this color, you must select the newly created material and navigate to the Inspector window. For instance, this first material can be named Red. When naming the material, it’s recommended to give it a name that correlates with its color. To create these materials, navigate to the Materials folder and right-click again, this time selecting Create -> Material. These materials are used to change the colors of different objects following whatever material the Scriptable Object specifies. While you’re here, it’s a good idea to go ahead and get three materials made. In your Assets window, you’ll need to create three folders by right-clicking the window and navigating to Create -> Folder as shown in Figure 3 Name the folders Materials, Scriptable Objects, and Scripts. Once the project is created, you’ll want to get organized. It’s recommended you use this template if you wish to follow along.įigure 2: Setting the project name, type, and location While you can perform this project in any template, this example uses the 3D project template as shown in Figure 2. In the next window, give the project any name of your choosing and decide on the file path. Project SetupĪssuming you’ll be implementing these ideas in a new project, open up the Unity Hub application and create a new project as shown in Figure 1. Now that you have an end goal, it’s time to get creating. A simple user interface displays these values so you can easily see the results of applying Scriptable Objects. Those values are maximum health, attack, defense, speed, and a name and color for the character. Each character inherits some values from a Scriptable Object. The project consists of three game objects meant to represent three characters. This project shows off Scriptable Objects and how they can help you. It’s always helpful to see these things in action, create a new project. Now with Scriptable Objects, you only need to change one object (the Scriptable Object) and all objects getting data from that Scriptable Object change at the same time. Before if you wanted to change an item’s stats, you’d have to change the values of every single copy of the item. Then that Scriptable Object is referenced by all copies of the item. In the above example, a single Scriptable Object can be used to define what the different properties of an item are. Then the Scriptable Objects are created from that template, which are then used by Unity game objects. The Unity developer creates a basic template for these containers, defining what information each object should contain. And what are Scriptable Objects? Simply put, they are data containers. To make things easier in a situation like this, you have Scriptable Objects at your disposal. Even if you’re not in a team, this method would just be harder on you as you work. This especially becomes an issue if you have a larger team to work with, so you’ll want to make things easier to change for other team members. ![]() In addition, if you must make any changes to the in-game objects, it’s simply not as efficient to do so when there are several copies of prefabs lying around. For starters, this method uses up more of your memory, something you may need to conserve if you plan on making a large game. While you could use Unity prefabs to do this and then change the values of each individual copy of the prefab, this is an inconvenient way to go about the task. Suppose you’re making a role-playing video game and you need an easier way to assign statistics, properties, and much more to various items.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |