Reader small image

You're reading from  Torque 3D Game Development Cookbook

Product typeBook
Published inJan 2013
Reading LevelIntermediate
PublisherPackt
ISBN-139781849693547
Edition1st Edition
Languages
Right arrow
Author (1)
DAVID WYAND
DAVID WYAND
author image
DAVID WYAND

David Wyand has been using GarageGames' Torque Game Engine for the past 10 years. Among his other interestes are 3D graphics applications, computer networking and Artificial Intelligence for computer games.
Read more about DAVID WYAND

Right arrow

Changing the material of a ShapeBase object using script


While a game is running we may want to modify the materials used by an object based on some event. For example, in a base-capture game we want the base's flag to show the current team's colors. This process of changing an object's materials is called changing an object's skin in Torque 3D. In this recipe we will modify an object's materials at any time using TorqueScript.

Getting ready

Modifying an object's materials while a game is running is very similar to skinning using the World Editor. In preparation for this recipe, please see the How to skin an object in the World Editor recipe in Chapter 2, Working with Your Editors, and set up all of the materials and the object to be skinned as described there.

How to do it...

Use the ShapeBase setSkinName() method to change an object's materials. To modify an object from using base_ materials to team1_ materials, make the following method call (with the object referenced using the %myObject...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Torque 3D Game Development Cookbook
Published in: Jan 2013Publisher: PacktISBN-13: 9781849693547

Author (1)

author image
DAVID WYAND

David Wyand has been using GarageGames' Torque Game Engine for the past 10 years. Among his other interestes are 3D graphics applications, computer networking and Artificial Intelligence for computer games.
Read more about DAVID WYAND