Game Development Community

A few newbie tech questions.

by William Johnson · in Torque Game Engine Advanced · 06/06/2008 (10:19 pm) · 1 replies

Hi there. I'm a new TGEA user that's pretty experienced with C++ but new to Torque. After seeing the ending credits of the Penny Arcade game and finding out they used Torque, I decided to check it out. I'm pretty much a newbie but I have read all the overview docs that ship with the game and I've been poring over the forums and code for the past couple days.

So far I've made a separate project, gotten everything to compile, created a mission with nothing but a flat terrain in it, and I'm just testing rudimentary stuff.

1) Help me understand the nuances of the datablock system.

First thing I did, just for kicks, was create a new type of particle emitter that sends up green smoke. I got this set up in script by copying one of the preexisting emitters and got it into my test mission easily enough, worked fine.

Then I created a trigger that turned the particles from green to red when I stepped in it. This took some doing but I eventually figured it out.

Then I created a few more particle emitters using my same green smoke cloud, but I discovered that when I stepped in my trigger brush, they ALL changed colors instead of just one. After looking at the code I wasn't really SURPRISED by this (they all have the same datablock pointer and the color is stored in the datablock) but I was very disappointed.

I couldn't find a way to modify just the one particle emitter while leaving the others alone. This seems pretty crippling to me. Suppose I wanted a thousand particle emitters, each with a different color. Would I really have to create a thousand different datablocks? Doesn't that defeat the entire purpose of datablocks in the first place, which is to reduce the amount of repeated information in the engine?

Shouldn't I be able to derive an object from a datablock, preserving most of the information, and then just change whichever fields I want per-instance? I'm sure someone has run into this situation before but I can't find any solutions.

2) Help me understand the client/server distinction

How do I tell whether I'm running on the client or the server?

Why are things like particles, that are just for looks and not affecting the actual outcome of the game, being implemented/defined in the server side scripts?

Browsing the code, I see some of the events/handler methods in each class are called for both client and server, and some are only called on the client, and some only on the server. However, it's definitely not clear from the method names which is which, is there any doc on this?

3) SimComponent

The shapeBase and Player classes that ship with Torque are kind of a mess (not to mention completely useless for my planned game design) and I was looking for a good guide on ripping them out and starting from scratch. I didn't have much luck finding such a guide but as I was searching I came across a lot of talk about a "component system."

After reading about it, it sounded exactly like what I was looking for. I took a look at the code in SimComponent and I can tell it's the system I want to be writing my code to, but it's a little bit opaque as far as how it's supposed to work.

I think I get the basic idea, which is that e.g. rather than creating a bunch of complicated classes that all do their own physics, you create a physics component and "install" it on componentized objects to add physics. But I don't understand how to create interfaces or apply them to objects.

Are there any examples anywhere for getting started with using these? A guide to implementing a simple GameBase-type object using components would be very helpful.

About the author

Recent Threads


#1
06/07/2008 (1:29 am)
#1.: tdn.garagegames.com/wiki/TorqueScript/Datablocks

It sounds to me like your accessing the datablock instance and not the object instance. How are you putting the particles in game (might help to see your code).


#2.: tdn.garagegames.com/wiki/Torque/Networking/Server_and_Client#Introduction