Game Development Community

Vector Methods?

by Brian Kelly · in Torque Game Builder · 08/29/2006 (5:20 pm) · 3 replies

What are the methods I can call on a vector?

Specifically, I want to access the X and Y values of a %normal passed in to a collission callback.

#1
08/29/2006 (7:04 pm)
There are no types in Torquescript, and thus no proper methods for "vectors". Now there are vector manipulation functions like t2dVectorAdd/Sub/Scale etc. Basically equivilants for all TGE's standard 3d vector functions. But for extracting x and y values from a "vector", which is just a string in TS, you would use getWord(%normal, 0) to get the x and getWord(%normal, 1) to get the y.
#2
08/29/2006 (7:07 pm)
Ick. I guess that will have to do for now.

Thanks for the reply!
#3
08/29/2006 (10:06 pm)
Just to clarify a little bit, TorqueScript is typeless - everything is stored as a string. But there is a vector format, that is: the X and Y values delimited by a single space. That is what most of the vector manipulation functions take as input, and is also the format that most of them return.

Here is a list of all the vector functions.

Edit: Forgot this was the public forums. That link won't work without a TGB license.. so here's a quick list:

t2dVectorAdd(%vector1, %vector2)
t2dVectorSub(%vector1, %vector2)
t2dVectorMult(%vector1, %vector2)
t2dVectorDot(%vector1, %vector2)
t2dVectorCompare(%vector1, %vector2, [%epsilon = 0.0001])
t2dVectorDistance(%vector1, %vector2)
t2dAngleBetween(%vector1, %vector2)
t2dVectorNormalise(%vector)
t2dVectorScale(%vector, %scale)
t2dVectorLength(%vector)