Game Development Community

A couple of questions

by Chris Sargent · in Torque 3D Professional · 12/27/2010 (5:03 pm) · 3 replies

Been about a month or so since I've been on these forums. I have been using Unity 3d to prototype my game concepts since I can get it done much quicker there and then transfer my work to Torque. I had a question about scripting.

The biggest thing that Unity allows with their Unity Script is that I can access variables in other scripts. Like for instance batteryCharge.charge = 4 Where batterCharge is another script and charge is the variable in that script. Can we do this in Torque Script or do I have to conatantly redefine a variable that may have uses throughout several scripts?

Thanks!

#1
12/27/2010 (6:05 pm)
Having script.variables that can be called just like that seems messy to me. Encapsulation is weak, and values can be off.

Anyways, we have our global variable type $ so it's possible to do that.

#2
12/27/2010 (6:35 pm)
It works good for there, but as Torque is my engine of choice I was curious if we could do that here as well.
#3
12/28/2010 (8:57 am)
Chris, hope understood you right, but in Torque you can define global objects and variables, they are avaiable in the whole system.
A good choice would be to use the variable tree, were all objects are avaiable. I used this in my scripts and it worked very well!