This page has been translated automatically.
Getting Started
Migrating to UNIGINE 2.0
C++ API Migration
UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
Samples
Usage Examples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Adding Materials to Cars

This article is a tutorial that will help you to assign random materials to your car into City Traffic. It is assumed that you have already imported a car to City Traffic by using this article.

To assign a random material to a car, you should create different materials and create a property. Your materials can be inherited from different base materials and assigned by using a property

Requirements

  • It is supposed that you already have an exported 3D model of a car, 3D model of wheels and necessary textures.
  • It is supposed that City Traffic has been already installed.
  • It is supposed that you have already created materials for your cars.

See Also

Creating Materials

To assign materials to a car by using a property you should create them. We suppose that you created materials by following instructions of the Assign Material section of the Adding Object into a New World tutorial.

Creating a Property

This section shows how to create a new property for a car to assign two different materials to the surfaces of a car.

  1. Open the Properties window in City Traffic by pressing O or click Windows -> Properties on the Menu bar.

  2. Choose the car_colors property and click the Inherit property button.

  3. In the window that opens, specify the name of the property.

    This property can assign only one material to the surface. To specify all of the necessary surfaces and their materials, you need to create auxiliary children, inherited from this property.
  4. Choose the created property and click the Inherit property button to create a child property.
    Notice
    This property will contain child properties for each surface of a car. The engine will take this parent property and assign all the materials that you specified in the children properties.

  5. Create a new child property for each surface which material you want to be changed.

  6. Specify Material and Surface in the Parameters tab for each property.

    Notice
    When you set the parameter for the parent node, child nodes change their default properties automatically.
  7. Click the Save properties button to save all the changes.

Assigning Property to a Car

After creating the property, you need to assign it to the car entity to City Traffic. To assign the property you should do the following:

  1. Open the Game Framework plugin window by clicking Plugins -> Game Framework.
  2. In the window that opened, choose created car entity.
  3. Select the Entity Fields tab, and fill the Color Base Property with the name of the created property.

  4. Click the Save Game button and launch the level.

    On the car's creation, the materials will be chosen randomly. The property will check all of the children and assign materials to required surfaces.
Last update: 2017-07-03
Build: ()