PacktLib: Torque 3D Game Development Cookbook

Torque 3D Game Development Cookbook


About the Author

About the Reviewers


TorqueScript: The Only Script You Need to Know


Accessing delimited fields within a string

Iterating on words in a string list

Retrieving components of a variable using accessors

Iterating on objects in a SimSet or SimGroup collection

Getting a random object from a SimSet or SimGroup collection

Finding an object in a SimSet or SimGroup collection using its internal name

Executing a method on a SimSet or SimGroup collection

Creating a new SimObject instance

Creating a new internal name only SimObject instance

Creating a new Datablock object

Creating a new singleton

Extending a SimObject instance using the class property

Using a variable to access methods or properties of a SimObject instance

Using call() to call a variable method on a SimObject instance with arguments

Using call() to call a variable function with arguments

Using script arrays as dictionaries

Using ArrayObject and custom script sorting callbacks

Scheduling SimObject methods

Scheduling functions

Activating and deactivating a package

Working with Your Editors


Setting up fogging of the level

How to cover seams and texture changes using decals placed in the World Editor

Copying the transform of an object to another in the World Editor window

How to change the material of an object in the World Editor

Setting up a glow mask using the Material Editor window

Using a convex shape as a zone

Setting zone-specific ambient lighting

Grouping adjacent zones together

Graphical User Interface


Creating a password text edit box

Using pushDialog() and popDialog() and setting up the UI file to work with them

Displaying metrics (such as FPS) from the console

Displaying a list of all game objects

Displaying a level at the main menu

Dragging and dropping between two windows

Camera and Mouse Controls


Locking and hiding the mouse while the right mouse button is down

Clicking on an object in the scene (client-side)

Clicking on an object in the scene (server-side)

Picking up an item in the scene while the mouse is locked and hidden

Changing the camera's view and control mode

Giving the camera smooth movement

Having the camera follow a path

Your Graphics Evolved


Using the built-in video recording

Changing the material of a ShapeBase object using script

Building a custom material

Building a custom material using advanced lighting

Building a postFX

Make That Sound Happen


Playing a quick 2D or 3D sound on all clients

Using SFXEmitter to create networked sound effects

Playing a sound on a ShapeBase object

Playing music while a level is loading

How to have a background sound for a level

How to have music change according to the mood

Triggering an event during sound playback

Game Objects


Playing an animation sequence on a TSStatic class

Playing an animation sequence on a ShapeBase class

How to make it rain using a Precipitation object

Using the Lightning object to automatically create a thunderstorm

Using the TimeOfDay object to generate events

Multiplayer Servers


How to start a dedicated server

What ports are needed to be open or forwarded for a multiplayer server

Passing arbitrary parameters from the client to the server

How to become an admin on a server

Kicking and banning people from the server

Stopping a server from restarting when the last player leaves

Accessing the server connection from the client

How to access all client connections from the server

Broadcasting a message to all clients and having it displayed in the center of the screen

Importance of Networking


Sending a network event from the client to the server

Sending a network event from the server to the client

Connecting as a TCP client

Setting up a TCP server

Connecting as an HTTP client

Using an RSS feed for game news, message of the day, or other client messages

How to activate, deactivate, and use Telnet for console access

Miscellaneous Gameplay Features


How to have a sprinting player use up energy

Enabling and disabling air control

How to jump jet

Adjusting the fire spread of a weapon

Changing the number of shots fired from a weapon

Making a weapon use energy rather than ammo

Finding objects in range

Using the message producer/consumer system