Game Development Community

Pointer Happiness

by Kevin James · in Torque Game Builder · 03/28/2005 (5:45 am) · 1 replies

I was overjoyed to discover how easy and intuitive it was to implement pointers in torquescript. Playing with the Basic Tutorial, I wanted to access the thruster object in the keypress functions. I added this line to AttachThruster:

if (%mountObj==$player)
$player.thruster = %thruster;

Now I can access the player's thruster anywhere I want without doing something stupid like make the thruster global. Very cool.

About the author

Computer security, digital forensics, and platform jumper enthusiast. shells.myw3b.net/~syreal/


#1
03/28/2005 (5:58 am)
Do keep in mind that while this does what you want to do, they are not actually "pointers" in the C/C++ sense, but the actual object ID's. In this particular case, the net functionality is the same, but you don't have the reference/dereference capabilities that you can use source code pointers for.

That being said, you are correct--you can do all sorts of nifty things like that--just be careful about how you use them--you won't crash (most of the time), but if you use this technique, you don't have any auto-magical cleanup if the %thruster object is deleted, for example.