Documentation/Tutorials/Creating a simple game object
From NeoAxis Engine Wiki
| Language: | Status: | Approved |
Contents |
Introduction
Almost every project has a lot of static objects on the map. For example tunnels, separate rooms, hallways, rocks, towers, buildings, etc. There are two ways to make this kind of objects:
- With StaticMesh.type.
- With a game object (.type file) created with Resource Editor.
Each method has it pros and cons:
1. There is no need for a special type for created object. You simply place the model (.mesh file) on the map and configure settings for each objects location. This method is used to create a large static objects (buildings, rooms and geometry, etc.).
2. With the second method, you must first create a game object type (.type file) and then place that object on the map. This way you can configure an object once and then simply place it on the map. Required properties will already be configured. Also it is better to use this method if you want to add more interactivity than plain collision.
Here we will describe the second method.
Description
This lesson will help you understand the process of creating a new game object. As an example, we will go through the creation of a custom stone.
To start this lesson, we need to prepare resources (stone model, material and texture).
Resources for tutorial
You can import any model or use an existing one. To learn how to import models from 3dsMax read the lesson about exporting models from Autodesk 3ds Max.
We will use the pre-made model of stone, which is already in the standard package NeoAxis Engine.
Start the Resource Editor. For our new type, we will need the following files: MyStone.dds, MyStone.HighMaterial, and MyStone.mesh. Navigate to the folder Bin\Data\Types\StaticObjects\Stone\ and copy the files into a separate folder. Select Stone.dds, Stone.HighMaterial, and Stone.mesh files by holding the Shift key, then right click and select Copy.
Now lets create a new folder in Bin\Data\Types\StaticObjects and name it MyStone.
Right click on the StaticObjects folder and select New Directory. Call it MyStone, and right click on it to Paste the 3 files into it.
Open the folder by clicking on the small + icon in front of the folder's name. You will see the files you just copied.
Then rename the files Stone.dds, Stone.material, and Stone.mesh to MyStone.dds, MyStone.material, and MyStone.mesh. To do this we need to selected the file, right-click and select Rename. The file's name will be available for editing. Also you will see that when editing the material (*.highMaterial), a special window pops up that displays the proposed name. You can use it or specify another name.
When you change the file name, note its extension becomes available for editing as well (extension is the part of the name at the end of the file after the point). To avoid the problems do not change the extension. Note that for some types of resources (materials, types) names should be unique within the project.
Creating a new .type file
Next we proceed directly to the creation of a new .type file for our future needs.
*.type (type of game object) is the main configuration file describing the game object. It contains its basic parameters and allows managing it.
Right-click on the MyStone folder. From the menu select New Resource.
Now you can choose the type of the resource. Select Entity Type.
You need to select the object class type. Choose MapObject. Classes define the behavior of object types. MapObject is the base class for most ordinary objects.
Let's call our new type MyStone.
We created a new .type file. Right-click on MyStone.type and select Edit. This activates the properties window on the right, as well as the viewing window in the center represented by a green border.
Now we need to attach a model (mesh) to our object. To do this right click on the preview window (surrounded by the green line) and select Attach Object → Mesh. This opens a dialog window and allows you to select the model - Data\Types\StaticObjects\MyStone\MyStone.mesh.
Now we can see the model on the screen. We also see it in the list attached objects. In order to make other objects (such as our character) not able to pass through the stone, we need to adjust the the collision. For this purpose you need to select the attached model from the list and set the model's Collision property to True. Now the physics of collisions will be counted on the basis of model's geometry.
You may have noticed that the frame in the preview window is green, then yellow. The yellow frame indicates that the object was changed, but has not yet been saved.
If you want to use this object for placement in the map editor you need to configure some more options:
- Set AllowEditorCreate property to True. This will allow the object to appear in the list of created objects in the map editor.
Now you should save the changes. You can do this by clicking the Save button.
Congratulations! Creation of a game object is now complete.
Placing Game Object in Map Editor
You can now use Map Editor to place your objects.