Game Development Community

Help with vector components

by Andross · in Torque Game Builder · 12/17/2006 (12:24 pm) · 2 replies

I've just started with the TGB trail and don't have a whole lot of experience with object-oriented languages like Torque Script. I use MEL (Maya Embedded Language) quite extensively and am trying to figure out how to do somethings I've done in with with Torque.

Right now I'm trying to get the sign of the X component in a vector and I can't seem to find any methods to get this, nor even how to work get the value of a single vector component. Any help would be appreciated.

About the author

Recent Threads


#1
12/17/2006 (12:43 pm)
If I'm understanding your question correctly, vectors as viewed from torque script are just strings, such as "3 5 2", representing x,y and z respectively (if it's a 3d vector, without the 'z' if it's a 2d vector).

To get one of the components, use the standard 'getWord' substring accessors, like this:
%vec = "3 4 2";
  %x = getWord(%vec,0);
  %y = getWord(%vec,1);
  %z = getWord(%vec,2);

There are several variations, such as 'getWords' to return multiple components, etc...
#2
12/17/2006 (1:04 pm)
Great thanks Brian. That's what I needed.